如何从JavaScript打开一个jQuery Mobile的对话? [英] How to open a jQuery Mobile Dialog from javascript?

查看:148
本文介绍了如何从JavaScript打开一个jQuery Mobile的对话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对话页面,我试图从一个AJAX POST打开它,并显示结果。

I have a dialog page and am trying to open it and display results from an AJAX POST.

下面是我的jQuery的成功事件:

Here is my jQuery success event:

success: function(resp) {                               
  $("#dialog").dialog();
  $("#text").html('SPAM and EGGS!')
}       

我的HTML有两页,第二个是在对话框的html:

My HTML has two pages, the second being the dialog html:

<div data-role="page" id="main">
  # content 
</div>
<div data-role="page" id="dialog">
  <div data-role="header">
    <h1>Your Message</h1>
  </div>    
  <div data-role="content" id="text">
  </div>    
</div>

我的AJAX POST正在和元素的id =文本正在更新垃圾邮件和鸡蛋!,但该对话框不会弹出。

My AJAX POST is working and element id="text" is being updated with "SPAM and EGGS!", but the dialog is not popping up.

推荐答案

添加&LT; A&GT; 标记中的任何地方你的网页,只要把你的对话框的id作为HREF如图所示下面: &LT;一个ID ='lnkDialogHREF =#对话框中的数据相对=对话框中的数据转换=啪的风格=显示:无;&GT;&LT; / A&GT;

Add <a> tag anywhere in your page, just put your dialog's id as href as shown below: <a id='lnkDialog' href="#dialog" data-rel="dialog" data-transition="pop" style='display:none;'></a>

和替换 $(#对话)对话框(); 您的成功事件里面 $(#lnkDialog)点击();

And replace $("#dialog").dialog(); inside your success event with $("#lnkDialog").click();

这篇关于如何从JavaScript打开一个jQuery Mobile的对话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆