javascript - jquery UI 模式不会导致回发

标签 javascript c# jquery asp.net

我有一个 jquery UI 模式,它在单击复选框时打开,并在单击“确定”按钮后导致回发,但它不起作用。我已经尝试了所有解决方案。请帮助。Asp.net 按钮位于表单标记内。

$("#dialog").dialog({
    modal: true,
    autoOpen: false,
    title: "Other-Legend",
    width: 300,
    open: function (type, data) {
        $(this).parent().appendTo("form");
    },
    buttons: {
        Ok: function () {
            $("[id*=btnConfirm]").click();
        },
        Close: function () {
            $(this).dialog('close');
        }
    }
});

jQuery('input[type="checkbox"]').click(function () {
    var parentClass = jQuery(this).parent('td').attr('class');         
    var checked = jQuery(this);
    jQuery('.' + parentClass.substring(0, parentClass.length - 8) + ' input[type="checkbox"]').each(function (i, e) {
        jQuery(this).prop('checked', false);
    })
    jQuery(checked).prop('checked', true);
    if (parentClass.indexOf("mdclass") >= 0) {          
        $('#dialog').dialog('open'); }
});

<asp:Button ID="btnConfirm" runat="server" Text="Button" style="display:none" OnClick ="Button1_Click" />

最佳答案

您可以尝试添加 jQuery UI v1.10 或更高版本的语法,将模式 DIV 附加到表单。

$("#dialog").dialog({
    modal: true,
    autoOpen: false,
    title: "Other-Legend",
    width: 300,
    appendTo: "form",
    buttons: {
        Ok: function () {
            $("[id*=btnConfirm]").click();
        },
        Close: function () {
            $(this).dialog('close');
        }
    }
});

关于javascript - jquery UI 模式不会导致回发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42264285/

相关文章:

javascript - 根据索引更改选择选项(Jquery)

javascript - 如何显示html元素

javascript - 在razor中使用javascript转换模型属性值

c# - System.Windows.Forms.Cursor.Position 和 setCursorPos 之间的区别?

javascript - 页面顶部和底部的 Bootstrap 3 导航选项卡?

javascript - Kendo Multiselect 具有箭头图标和单击时关闭的行为

c# - Entity Framework 有时不加载子对象/集合的内容

c# - 如何使用 ConfigurationManager 打开配置文件应用程序设置?

javascript - 存储默认值并在点击事件中进行比较

javascript - UI-路由器 : param values not valid for state