2

I'm creating a website, and I used jQuery 1.8.3 with jQuery-ui 1.9.1.
But for some reason, I need to upgrade to jQuery 1.9.0. I didn't change the jQuery ui version, and I have the following error :

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

The code raising this error is the following :

function displayEditPreferencesPopup(param1, param2)
{
    $("<div></div>")  
        .dialog({
            title: "My popup title",  
            modal: true,  
            height: 400,  
            width: 600,  
            left: 0,
            close: function () { 
                $(this).remove();
            },
            buttons: {
                Cancel: function() {
                    $(this).dialog("close");
                },
                "Edit Preference" : function() {
                    EditPreferences(); //Send some data to save in DB
                    $(this).remove();
                }
            }
        }).load('@Url.Action("Edit", "Preference")', { 'param1' : JSON.stringify(jsVariable1) , 'param2' : JSON.stringify(jsVariable2) });
        //last line is Razor syntax (ASP.NET MVC3 project), it corresponds to "/Preference/Edit" with parameters
}

So, this was perfectly working with jQuery 1.8.3 but raises the error with jQuery 1.9.0.

I've seen this question on SO, which seems very close to mine, but I'm unable to adapt the answer to my problem (I'm new with jQuery).

Can someone help me ?
Thank you

Community
  • 1
  • 1
AlexB
  • 7,302
  • 12
  • 56
  • 74

0 Answers0