jQuery UI Dialog with ASP.NET button postback

前端 未结 17 1858
鱼传尺愫
鱼传尺愫 2020-11-22 14:43

I have a jQuery UI Dialog working great on my ASP.NET page:

jQuery(function() {
    jQuery(\"#dialog\").dialog({
        draggable: true,
        resizable:          


        
相关标签:
17条回答
  • 2020-11-22 15:07

    I know this is an old question, but for anyone who have the same issue there is a newer and simpler solution: an "appendTo" option has been introduced in jQuery UI 1.10.0

    http://api.jqueryui.com/dialog/#option-appendTo

    $("#dialog").dialog({
        appendTo: "form"
        ....
    });
    
    0 讨论(0)
  • 2020-11-22 15:07

    Use this line to make this work while using the modal:true option.

    open: function (type, data) { 
        $('.ui-widget-overlay').appendTo("form"); $(this).parent().appendTo("form"); 
      },
    
    0 讨论(0)
  • 2020-11-22 15:08

    The exact solution is;

    $("#dialogDiv").dialog({ other options...,
        open: function (type, data) {
            $(this).parent().appendTo("form");
        }
    });
    
    0 讨论(0)
  • 2020-11-22 15:10

    ken's answer above did the trick for me. The problem with the accepted answer is that it only works if you have a single modal on the page. If you have multiple modals, you'll need to do it inline in the "open" param while initializing the dialog, not after the fact.

    open: function(type,data) { $(this).parent().appendTo("form"); }
    

    If you do what the first accepted answer tells you with multiple modals, you'll only get the last modal on the page working firing postbacks properly, not all of them.

    0 讨论(0)
  • 2020-11-22 15:14

    FWIW, the form:first technique didn't work for me.

    However, the technique in that blog article did:

    http://blog.roonga.com.au/2009/07/using-jquery-ui-dialog-with-aspnet-and.html

    Specifically, adding this to the dialog declaration:

      open: function(type,data) {
        $(this).parent().appendTo("form");
      }
    
    0 讨论(0)
  • 2020-11-22 15:14

    Fantastic! This solved my problem with ASP:Button event not firing inside jQuery modal. Please note, using the jQuery UI modal with the following allows the button event to fire:

    // Dialog Link
    $('#dialog_link').click(function () {
        $('#dialog').dialog('open');
        $('#dialog').parent().appendTo($("form:first"))
        return false;
    });
    

    The following line is the key to get this working!

    $('#dialog').parent().appendTo($("form:first"))
    
    0 讨论(0)
提交回复
热议问题