How to open a jQuery Mobile Dialog from javascript?(如何从 javascript 打开 jQuery Mobile 对话框?)
问题描述
我有一个对话框页面,正在尝试打开它并显示来自 AJAX POST 的结果.
这是我的 jQuery 成功事件:
成功:函数(resp){$("#dialog").dialog();$("#text").html('垃圾邮件和鸡蛋!')}
我的 HTML 有两个页面,第二个是对话框 html:
我的 AJAX POST 正在运行,元素 id="text" 正在更新为SPAM 和 EGGS!",但没有弹出对话框.
解决方案 在页面的任意位置添加 <a>
标签,只需将对话框的 id 作为 href 如下所示:<a id='lnkDialog' href="#dialog" data-rel="dialog" data-transition="pop" style='display:none;'></a>
并将成功事件中的 $("#dialog").dialog();
替换为$("#lnkDialog").click();
I have a dialog page and am trying to open it and display results from an AJAX POST.
Here is my jQuery success event:
success: function(resp) {
$("#dialog").dialog();
$("#text").html('SPAM and EGGS!')
}
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>
My AJAX POST is working and element id="text" is being updated with "SPAM and EGGS!", but the dialog is not popping up.
解决方案 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>
And replace $("#dialog").dialog();
inside your success event with
$("#lnkDialog").click();
这篇关于如何从 javascript 打开 jQuery Mobile 对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 javascript 打开 jQuery Mobile 对话框?


基础教程推荐
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01