[英]Issue with open a Popup / Dialog box in javascript
I have a dynamic select box in my application. 我的应用程序中有一个动态选择框。 On click of any list item I need to show the item details in popup. 单击任何列表项后,我需要在弹出窗口中显示项目详细信息。 But I'm unable to open the popup/dialog box which is not happening now, my code is, 但是我无法打开现在没有发生的弹出/对话框,我的代码是,
$( "#locationList" ).on( "click", "li", function( event ) {
alert("click event");
$.mobile.changePage('#myPopupDialog', 'pop', true, true);
});
I'm able to see the alert, but dialog box is not opening. 我可以看到警报,但是对话框没有打开。
<div data-role="dialog" id="dialog">
<div data-role="header">
<h1>List Item details</h1>
</div>
<div data-role="main" class="ui-content">
<h2>Welcome to my Popup Dialog!</h2>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
List elements should come dynamically from Db, like, 列表元素应动态来自Db,例如,
var optionheading = '<li value="Select Location">Select Location</li>';
for (var i = 0; i < res.rows.length; i++)
{
var opt = '<li value="';
opt += res.rows.item(i).Location;
opt += '">';
opt += res.rows.item(i).Location;
opt += '</li>';
$("#locationList").append(opt);
}
$("#locationList").listview('refresh');
HTML: HTML:
<ul data-role="listview" id="locationList" data-dismissible="false" style="height: 150px;border:1px solid #ccc;background:#f2f2f2;font:normal 11px/15px arial;padding:6px;color:#333; overflow: auto" name="locationList" data-inset="true">
</ul>
any suggestions!! 有什么建议么!!
Your dialog has 您的对话框有
id="dialog"
However your javascript is trying to popup a dialog with an id of myPopupDialog: 但是,您的JavaScript试图弹出一个ID为myPopupDialog的对话框:
$.mobile.changePage('#myPopupDialog', 'pop', true, true);
These IDs must match! 这些ID必须匹配!
If you are using jQM 1.4.x, your dialog page should use data-dialog="true": 如果使用的是jQM 1.4.x,则对话框页面应使用data-dialog =“ true”:
<div data-dialog="true" id="myPopupDialog">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.