JQuery Error "Unaccepted TypeError: Unable to read property 'apply' from undefined"

I am including an OK button in the jQuery dialog based on the changes in the Select box.

This part works, but when I click OK or Close to save this information and continue, the following errors appear.

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

Firefox: TypeError: d.click - 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);
    }
});

      

Here's a JSFiddle overtakes the problem to its bare minimum: JSFiddle Button Error

+3


source to share


1 answer


You need to change "Ok" to "click" for the buttons.

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

+3


source







All Articles