【问题标题】:Why does jQuery Mobile Simple Dialogue freeze when users click too fast?当用户点击太快时,为什么 jQuery Mobile 简单对话会冻结?
【发布时间】:2012-03-22 03:13:50
【问题描述】:

我正在使用 simpledialog2 在我的 jQuery Mobile 应用程序中创建对话框。

至少在 Google Chrome 中,如果用户通过单击其中一个列表视图项打开对话框,然后将其关闭,然后立即打开另一个,则当用户单击列表项时,对话框将不再打开。

这是jsFiddle

为什么?

这是我的 HTML。

<ul data-role="listview">
    <li><a href="#">foo</a></li>
    <li><a href="#">bar</a></li>
    <li><a href="#">baz</a></li>
</ul>​

和 Javascript。

$(function() {

    // When user clicks on a list item, produce a dialogue/alert box.
    $('[data-role="listview"] a').click(function(event) {
        event.preventDefault();
        $('<div>').simpledialog2({
                mode: 'blank',
                headerText: "Popup title",
                headerClose: true,            
                dialogForce: true,
                blankContent: 
                "My message to you."
        });
    });
});

【问题讨论】:

    标签: javascript jquery jquery-plugins jquery-mobile


    【解决方案1】:

    使用常规 jQuery 和 jQuery mobile 编写的主要区别之一是您使用

    $(document).bind('pageinit', function() {
      // code here
    });
    

    而不是

    $(function() { 
      // code here
    });
    

    不确定如何解决您的具体问题,但一个好的开始是在您加载用 jquery mobile 编写的网站的代码时更改。

    【讨论】:

      猜你喜欢
      • 2013-08-19
      • 1970-01-01
      • 1970-01-01
      • 2012-05-19
      • 2015-05-22
      • 1970-01-01
      • 2012-07-13
      • 2023-03-22
      • 1970-01-01
      相关资源
      最近更新 更多