jQuery错误"未捕获的TypeError:无法读取属性' apply'未定义"

时间:2015-05-01 18:52:41

标签: javascript jquery

我根据对Select字段的更改在jQuery对话框中启用OK按钮。

该部分有效,但当我点击“确定”或“关闭”时,为了保存该信息并继续,出现以下错误。

  

Chrome:未捕获的TypeError:无法读取属性' apply'未定义的

     

Firefox:TypeError:d.click未定义

     

... e =" button">')。click(function(){d.click.apply(c.element [0],arguments)})... 。
  jquery-ui.min.js(第14行,第5350栏)

    var disposition;  // I'm using this so that the alert('fixed') doesn't get call on load...  

//  Callback Disposition Dialog
$('#disposition_modal').dialog({
    open: function () {  // removed the default close link
        $(this).parent().children(':first').children('a').remove();
    },
    buttons: [{
        text: 'Cancel',
        Ok: function () {
            $(this).dialog("close");
        }
    }, {
        text: 'OK',
        disabled: true,
        id: 'dm_btn',
        Ok: function () {
            if (disposition !== '' && undefined !== disposition) {
                alert('fixed');
                $(this).dialog("close");
            }
        }
    }]
});

// toggle the OK button 
$('#disposition_id_in2').change(function () {
    disposition = $('#disposition_id_in2').val();
    if ($('#disposition_id_in2').val()) {
        $('#dm_btn').attr('disabled', false);
    } else {
        $('#dm_btn').attr('disabled', true);
    }
});

这是JSFiddle将问题简化为最低限度的问题:JSFiddle button error

1 个答案:

答案 0 :(得分:3)

您需要更改"确定"到"点击"按钮。

buttons: [{
    text: 'Cancel',
    click: function () {
        $(this).dialog("close");
    }
}, {
    text: 'OK',
    disabled: true,
    id: 'dm_btn',
    click: function () {
        console.log(disposition);
        if (disposition !== '' && undefined !== disposition) {
            alert('fixed');
            $(this).dialog("close");
        }
    }
}]

jsfiddle

相关问题