【问题标题】:JQuery UI Asp.net 4jQuery UI Asp.net 4
【发布时间】:2011-09-07 08:52:42
【问题描述】:

我正在使用 JQueryUI 和 Asp.net 并遇到动态内容问题:

<div id="content" title="" style="color: #F7A356"> 
<%=ContentLabel.Text%>
</div>

    function OpenDialog() {

   // alert(document.getElementById("content").innerHTML);

        var $dialog = $('<div style="color: #F7A356"></div>')
            .html($("#content").text())
            .dialog({
                autoOpen: false,
                modal: true,
                height: 150,
            });


            $dialog.dialog('open');

    }

我想在单击控件并显示内容时打开一个对话框.. 但是上面的方法失败了....

即使我只是一个带有 innerHTML 的简单 javascript 警报函数,它也不起作用.....它也不返回任何内容

【问题讨论】:

    标签: asp.net jquery-ui dialog


    【解决方案1】:

    这应该是它的样子..

    $(document).ready(function() {
          .dialog({
             autoOpen: false,
             modal: true,
             height: 150,
         });
    
           $('a .opendialog').click(function(){
               $('#content').dialog('open');
           }
        });
    

    如果这没有帮助,请提供更多的 html

    【讨论】:

    • 注意它应该是$('#content') 而不是$('.content')
    【解决方案2】:

    您应该在打开对话框之前将新创建的元素添加到文档中。尝试类似:

    $('<div style="color: #F7A356"></div>')
        .html($("#content").html())
        .appendTo("body")
        .dialog({
            modal: true,
            height: 150
        });
    

    【讨论】:

    • 我试过这个方法。但它不起作用......函数 .html() 返回“”(无)。但是如果我最初在
      中放置一些文本,函数 .html() 可以将它们取出。但如果我使用 它什么也不返回
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-09
    • 2013-06-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多