我正在使用 simpledialog2 在 jQuery Mobile 应用程序中创建对话框。
至少在 Google Chrome 中,如果用户通过单击一个 ListView 项打开一个对话框,关闭它,然后立即打开另一个,则当用户单击列表项时,对话框将不再打开。
这是一个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 编写的网站代码的时间。
关于javascript - 为什么当用户点击太快时 jQuery Mobile Simple Dialogue 会卡住?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9815931/