为什么jQuery Mobile Simple Dialogue在用户点击过快时会冻结

Why does jQuery Mobile Simple Dialogue freeze when users click too fast?

本文关键字:冻结 用户 Mobile jQuery Simple Dialogue 为什么      更新时间:2023-09-26

我正在使用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."
        });
    });
});

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

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

而不是

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

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