jquery ui Dialog: cannot call methods on dialog prior to initialization

后端 未结 11 1808
既然无缘
既然无缘 2020-11-27 02:52

I have an app on jquery 1.5 with dialogs worked fine. While I have a lot of .live handlers, I changed this to .on. For that, I have to update jquery (now 1.8.3 an jquerui 1.

相关标签:
11条回答
  • 2020-11-27 03:24

    I simply had to add the ScriptManager to the page. Issue resolved.

    0 讨论(0)
  • 2020-11-27 03:25

    This is also some work around:

    $("div[aria-describedby='divDialog'] .ui-button.ui-widget.ui-state-default.ui-corner-all.ui-button-icon-only.ui-dialog-titlebar-close").click();
    
    0 讨论(0)
  • 2020-11-27 03:29

    I got this error message because I had the div tag on the partial view instead of the parent view

    0 讨论(0)
  • 2020-11-27 03:32

    In my case the problem was that I had called $("#divDialog").removeData(); as part of resetting my forms data within the dialog.

    This resulted in me wiping out a data structure named uiDialog which meant that the dialog had to reinitialize.

    I replaced .removeData() with more specific deletes and everything started working again.

    0 讨论(0)
  • 2020-11-27 03:36

    So you use this:

    var theDialog = $("#divDialog").dialog(opt);
    theDialog.dialog("open");
    

    and if you open a MVC Partial View in Dialog, you can create in index a hidden button and JQUERY click event:

    $("#YourButton").click(function()
    {
       theDialog.dialog("open");
       OR
       theDialog.dialog("close");
    });
    

    then inside partial view html you call button trigger click like:

    $("#YouButton").trigger("click")
    

    see ya.

    0 讨论(0)
  • 2020-11-27 03:38

    My case is different, it fails because of the scope of 'this':

    //this fails:
    $("#My-Dialog").dialog({
      ...
      close: ()=>{
        $(this).dialog("close");
      }
    });
    
    //this works:
    $("#My-Dialog").dialog({
      ...
      close: function(){
        $(this).dialog("close");
      }
    });
    
    0 讨论(0)
提交回复
热议问题