【问题标题】:dynamically enable disable datepick based on the dynamic status of the attached field根据附加字段的动态状态动态启用禁用日期选择
【发布时间】:2012-10-11 11:36:07
【问题描述】:

我认为这可能是 jquery-datepick.js(http://keith-wood.name/datepick.html) 中的错误

情况:

我有一个带有 datepick 的输入文本字段。默认情况下禁用此字段。所以 datepick 也被禁用(好吧,这很好)。现在,此字段基于单选按钮启用/禁用。我为此使用 jquery,它工作正常,除了 datepick 未根据字段的“动态状态”启用/禁用。

我尝试了什么

我尝试手动启用/禁用日期选择以及基于相同的单选按钮..像这样:

function enbDsb(id1, id2){
        var target = '#' + id2;
        if($('#' + id1).val() == 'Y'){
            $(target).removeAttr('disabled');
            if($(target).hasClass('hasDatepick')){
            /*alert("enable now");*/
            }
        }else{
            $(target).attr('disabled', true);
            if($(target).hasClass('hasDatepick')){
            /*alert("disable now");*/
            }
        }
    }

其中 id1=radio_id 和 id2= 文本字段 id(具有 datepick)

我用过

$(target).datepick({ disable: false });

还有这个

$(target).datepick({ disabled: false });

但没有一个工作...... :(

$.extend(Datepicker.prototype, {
    dataName: 'datepick',
    markerClass: 'hasDatepick',        
..........rest
}

^^以防万一有人要求使用 'datepicker' 而不是 'datepick'

请帮忙....谢谢!

【问题讨论】:

    标签: jquery html datepicker


    【解决方案1】:

    啊……

    解决了..!

    刚用过这个

    function enbDsb(id1, id2){
            var target = '#' + id2;
            if($('#' + id1).val() == 'Y'){
                $(target).removeAttr('disabled');
                if($(target).hasClass('hasDatepick')){
                $(target).datepick('enable');
                }
            }else{
                $(target).attr('disabled', true);
                if($(target).hasClass('hasDatepick')){
                $(target).datepick('disable');
                }
            }
        }
    

    它就像魅力一样!

    【讨论】:

      猜你喜欢
      • 2012-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-23
      • 2016-07-12
      • 2020-01-05
      相关资源
      最近更新 更多