附加jQuery UI的对话框ASP.NET表单文件准备就绪 [英] Append jQuery UI dialog to ASP.NET form on document ready

查看:111
本文介绍了附加jQuery UI的对话框ASP.NET表单文件准备就绪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET jQuery UI的对话框。我裹在对话框中的复选框的列表。因为,这是一个编辑页,有的复选框都已经检查
因为从数据获取datatbase网页时首次加载。

我没有问题,当我点击链接打开对话框,一切按预期工作。但是,如果我不点击链接,打开对话框,这些复选框
值不会从code-落后时提交表单回到回升。我理解,因为jQuery UI的对话框追加格为HTML体形式之外
当页面加载元素。

  //我想追加对话框的部门形成的文件准备这样,但没有工作
     。$(#对话框的部门)父()appendTo($(形式:一是));


  

如何使由ASP.NET页面所需的形式标签的jQuery用户界面对话框一部分,当第一次加载页面?


由于存在的页面不只是那些在复选框等诸多领域。有时,
有可能是不需要打开对话框,选择任何复选框。

下code行之有效只有当我点击链接打开对话框。

  $(文件)。就绪(函数(){        //对话框链接
        $('#dialog_link_dept')。点击(函数(){
            $('#对话框的部门)对话框(开放)。
            返回false;
        });        //启动对话
        $('#对话框的部门)。对话框({
            的AutoOpen:假的,
            宽度:700,
            模式:真实,
            开:功能(类型,数据){
                $(本).parent()appendTo(形式)。
            }
        });    });
< / SCRIPT>


解决方案

您可以将它移动到<形式> 创建后立即,即使它是的AutoOpen:假,就像这样:

  $('#对话框的部门)。对话框({
        的AutoOpen:假的,
        宽度:700,
        模式:真
    })父()appendTo(形式)。

I have jQuery UI dialog with ASP.NET. I wrap a list of check boxes in the dialog. Since, it's an "Edit page", some of the checkboxes are already checked because the data fetched from datatbase when page is first loaded.

I have no problem when I click on the link to open dialog, and everything works as expected. However, if I don't click on the link to open dialog, those checkboxes values will not be picked up from code-behind when form is submitted back. I understand because jQuery UI dialog append "div" to HTML body outside of the "form" element when the page is loaded.

    //I'm trying to append dialog-dept to form on document ready like this but not yet working
     $("#dialog-dept").parent().appendTo($("form:first"));

How do I make jQuery UI dialog part of "form" tag required by ASP.NET page when page first loaded?

Because there are many other fields on the page not just those checkbox. Sometime, there might be no need to open dialog to select any checkbox.

The code below works well only if I click on the link to open the dialog.

 $(document).ready(function() {

        // Dialog Link
        $('#dialog_link_dept').click(function() {
            $('#dialog-dept').dialog('open');
            return false;
        });

        // Launch Dialog
        $('#dialog-dept').dialog({
            autoOpen: false,
            width: 700,
            modal: true,
            open: function(type, data) {
                $(this).parent().appendTo("form");
            }
        });

    });
</script>

解决方案

You can move it into the <form> immediately upon creation, even if it's autoOpen: false, like this:

    $('#dialog-dept').dialog({
        autoOpen: false,
        width: 700,
        modal: true
    }).parent().appendTo("form");

这篇关于附加jQuery UI的对话框ASP.NET表单文件准备就绪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆