Alexander
Alexander

Reputation: 1687

JQuery Dialog Initialization

I continue getting this error when I click the close button (which doesn't close) on my JQuery Dialog:

Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'

in Chrome Tools after attempting a few of the suggested fixes on StackOverflow in other questions.

Can anybody point out where I am not structuring the dialog correctly to cause this error?

live fiddle here

$(document).ready(function fooDialog() {

    $('#fooChartDialog').dialog({
        autoOpen: false,
        height: 600,
        width: 1000,
        resizable: false,
        buttons: {
            "Drill Down Report": function () {
                window.open('example.com');
            },
            "Close": function () {
                $(this).dialog("close");
            }
        },
        open: function () {
            $('#fooChartDialog').load($('#fooChartDialog').data('url'), function () {
                fooChartLoad()
            });
        },
        title: 'Customer Satisfaction Chart',
        modal: true
    });

    $('#fooChartButton').click(function () {
        $('#fooChartDialog').dialog("open")
    });
});

Upvotes: 1

Views: 13560

Answers (1)

DB----
DB----

Reputation: 56

Try $(this).dialog("close"); instead of $('this').dialog("close");

current object should be referenced by $(this) not by $('this')

Upvotes: 4

Related Questions