【问题标题】:How to add action when jQuery Mobile dialog closedjQuery Mobile 对话框关闭时如何添加操作
【发布时间】:2013-08-15 02:29:24
【问题描述】:

我正在使用 jquerymobile。我想在对话框窗口关闭时添加一个事件,就像$( ".selector" ).on( "popupafterclose", function( event, ui ) {} ); 一样。给对话框小部件设置类似的事件。

【问题讨论】:

    标签: jquery jquery-mobile dialog


    【解决方案1】:

    dialog 小部件本质上只是页面小部件,其样式看起来像一个对话框,因此正常的页面事件仍会触发。根据您的问题,听起来pagehide 应该做您想做的事情,这是指向其他页面events 的链接

    例如

    HTML

    <div data-role="page">
        <div data-role="header"><h3>First Page</h3></div>
        <div data-role="content">
            <a href="#myDialog" data-rel="dialog" >Open Dialog</a>
        </div>
        <div data-role="footer"><h3>Footer</h3></div>
    </div>
    
    <div data-role="page" id="myDialog">
        <div data-role="header"><h3>A Dialog</h3></div>
        <div data-role="content">
            <p>A Dialog</p>
        </div>
        <div data-role="footer"><h3>Footer</h3></div>
    </div>
    

    JS

    $(document).on('pagehide', '#myDialog', function() {
       alert('Dialog hidden'); 
    });
    

    jsfiddle

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-13
      相关资源
      最近更新 更多