对话框_jQuerymobile

发布于 2024-10-08 14:43:09 字数 76 浏览 0 评论 0原文

我想根据Ajax结果打开对话框。 如何从 .js 文件创建/打开对话框?

任何人都可以帮助我。

提前致谢。

I want to open the dialog box based on the Ajax result.
How to create/open the dialog from the .js file?

Anyone help me.

THanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

暗地喜欢 2024-10-15 14:43:09

如果您只是链接到这样的文件:

打开对话框

无论如何,它都是使用 AJAX 完成的对于 JS 支持较少的人来说,可以很好地降级。

您想要的方式:

为您的内容创建一个包装 div 并为其指定一个 data-role=dialog 属性,然后对其调用 .dialog() ,或者.page() 如果对话框不起作用。
更新:
使用 JQMbeta2,他们引入了一个“创建”事件,您必须在东西上触发它,而不是使用 .page

if you just link to a file like this:

<a href="foo.html" data-rel="dialog">Open dialog</a>

it's done with AJAX anyway and degrades nicely for people with lesser JS support.

The way you want to do it:

Create a wrapping div for your content and give it a data-role=dialog attribute, then call .dialog() on it, or .page() if dialog doesn't work.
update:
With JQMbeta2 they introduces a 'create' event which you have to trigger it on stuff instead of using .page

清音悠歌 2024-10-15 14:43:09

不知道这篇文章是否仍然相关,但我是这样做的:

function openDialog(strPageId, strTransition){
    $.mobile.changePage($("#"+strPageId+":jqmData(role='dialog')"), {transition : ""+strTransition+""});    
}

然后你可以在按钮上或在你的代码中调用它,无论在哪里......

<button data-theme="a" name="btnOS" id="btnOS" onClick="openDialog('pu-edit-mailorder','slideup')">Order</button>

Don't know if this post is still relevant, but I did it like this:

function openDialog(strPageId, strTransition){
    $.mobile.changePage($("#"+strPageId+":jqmData(role='dialog')"), {transition : ""+strTransition+""});    
}

And then you can invoke it on a button, or in your code, wherever...

<button data-theme="a" name="btnOS" id="btnOS" onClick="openDialog('pu-edit-mailorder','slideup')">Order</button>
温暖的光 2024-10-15 14:43:09

我认为他的意思是他想使用 JS 打开 jQM 对话框,而不是创建对话框链接并触发单击事件。

如果是这样,你应该使用 $.mobile.changePage('pageURL', {role: 'dialog'});

I think he means he wants to use JS to open a jQM dialog, not create a dialog link and fire a click event.

If so you're supposed to use $.mobile.changePage('pageURL', {role: 'dialog'});

北陌 2024-10-15 14:43:09

由于某种原因, .dialog() 对我不起作用。我正在使用:

$("<a href='#dialog-id' data-rel='dialog'></a>").click().remove();

不太好,但有效。

.dialog() for some reason did not work for me. I am using:

$("<a href='#dialog-id' data-rel='dialog'></a>").click().remove();

Not really nice, but works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文