1

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")
    });
});
Alexander
  • 1,577
  • 5
  • 21
  • 35

1 Answers1

4

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

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

IT ppl
  • 2,626
  • 1
  • 39
  • 56
DB----
  • 56
  • 1
  • 6
  • @Alexander I can't see any error in fiddle. It's working fine by David's solution. – IT ppl Mar 22 '13 at 13:14
  • 1
    Same, I changed the reference for $(this) it works in the fiddle, but not on my local so I believe there is a deeper issue on my side. Thank you both. – Alexander Mar 22 '13 at 13:20