javascript - jQuery 错误 "Uncaught TypeError: Cannot read property ' 未定义的应用'

标签 javascript jquery

我根据对“选择”字段的更改在 jQuery 对话框中启用“确定”按钮。

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

Chrome: Uncaught TypeError: Cannot read property 'apply' of undefined

Firefox: TypeError: d.click is undefined

... e="button">').click(function(){d.click.apply(c.element[0],arguments)})....
jquery-ui.min.js (line 14, col 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

最佳答案

您需要将按钮的“确定”更改为“单击”。

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

关于javascript - jQuery 错误 "Uncaught TypeError: Cannot read property ' 未定义的应用',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29993196/

相关文章:

javascript - 在选择标签中使用 ng-click 的 Angular

javascript - Firefox 会在检索图像时显示它们吗?

javascript - jquery 将 HTML 代码更改为纯文本

javascript - 如果拖放太快,则不会调用可排序的放置处理程序

javascript - 来自属性的变量只显示第一个词

javascript - Node.JS-R,Python 繁重计算识别回调何时返回并存储该结果

javascript - 在 JavaScript Canvas 中沿直线移动一个点

ajax - jquery ajax - 全局设置。是否可以知道什么事件/元素触发ajax调用?

javascript - 如何从ajax获取表单ID并在symfony2的点击功能中设置它

javascript - 如何隐藏列表中不必要的重新排序箭头