【问题标题】:unable to display custom dialog box for dynamic elements无法显示动态元素的自定义对话框
【发布时间】:2015-07-23 09:42:59
【问题描述】:

我正在尝试通过单击按钮打开一个对话框,但它不适用于多行..意味着动态元素

jsp代码:

 <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
 <script src="//malsup.github.com/jquery.form.js"></script>
 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
 <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
//loop starts
<table>
<tr>


 <td style="" class="tdx" bgcolor="#CCCCCC"><a href=" <%=contextName%>/jsp/knowledgeBase/kbDetails.jsp?kbaseID=<%=kbaseID%>&app=<%=motsID%>&env=<%=env%>&env=<%=env%>&ptitle"=<%=pTitle%>><%=kbaseID%></a></td>

                <td style="" class="tdx" bgcolor="#CCCCCC"><%=motsName%></td>

                <td style="" class="tdx" bgcolor="#CCCCCC"><%=problemDescription%></td>

    <td class="tdx" bgcolor="#CCCCCC" style="" id="sol" style="background-color:white;border-style:ridge">

         <div id="dialog">

                <p><%=solution%></p>

         </div>
     <button id="opener">Open Dialog</button>
    </td>

        </tr>   
   </table>
//loop ends

jquery 代码:

  $(function() {
  $( "#dialog",this ).dialog({
   autoOpen: false,
   show: {
     effect: "blind",
     duration: 1000
   },
  hide: {
    effect: "explode",
    duration: 1000
  }
  });

  $( "#opener",this ).click(function() {
  $( "#dialog" ).dialog( "open" );
  });
  });

对话框打开只有一个条目时格式不好,动画不流畅

【问题讨论】:

    标签: javascript jquery jquery-animate


    【解决方案1】:

    &lt;button id="opener"&gt;Open Dialog&lt;/button&gt; 更改为&lt;button class="opener"&gt;Open Dialog&lt;/button&gt;&lt;div id="dialog"&gt; 更改为&lt;div class="dialog"&gt;

    然后

    $(function() {
        $('.dialog').dialog({
            autoOpen: false,
            show: {
                effect: "blind",
                duration: 1000
            },
            hide: {
                effect: "explode",
                duration: 1000
            }
        });
    
        $('.opener').click(function() {
            $(this).prev().dialog( "open" );
        });
    });
    

    【讨论】:

    • 你使用的是哪个dialog插件?
    • plugin 的意思是……抱歉没得到你
    • 你需要 jquery 插件来获得对话框弹出。网上有这么多可用的,我想知道你用的是哪一个
    • 然后在这里分享那个jsfiddle
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-14
    • 1970-01-01
    • 2016-10-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多