Jquery mobile,如何手动更改“pagebeforeload”上的页面事件

发布于 2024-12-29 06:11:57 字数 579 浏览 3 评论 0原文

我正在尝试使用文档中定义的方法重定向页面

$( document ).bind( "pagebeforeload", function( event, data ){

// Let the framework know we're going to handle the load.

event.preventDefault();

// ... load the document then insert it into the DOM ...
// at some point, either in this callback, or through
// some other async means, call resolve, passing in
// the following args, plus a jQuery collection object
// containing the DOM element for the page.

data.deferred.resolve( data.absUrl, data.options, page );

});

,但我不确定确切解析的参数是什么,我在任何地方都找不到文档,那里的页面参数到底是什么?

I'm trying to redirect a page using the method defined in the docs

$( document ).bind( "pagebeforeload", function( event, data ){

// Let the framework know we're going to handle the load.

event.preventDefault();

// ... load the document then insert it into the DOM ...
// at some point, either in this callback, or through
// some other async means, call resolve, passing in
// the following args, plus a jQuery collection object
// containing the DOM element for the page.

data.deferred.resolve( data.absUrl, data.options, page );

});

But I'm not sure what params exactly resolve is taking I can't find the docs anywhere, what exactly is the page param there?

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

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

发布评论

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

评论(3

Hello爱情风 2025-01-05 06:11:57

我遇到了同样的问题,我最终所做的是创建一个隐藏按钮,然后触发该按钮上的单击事件。我知道这可能不是正确的方法,但我想我会提供一个解决方案/黑客。如果其他人有更好的东西,我真的很想听听。

JS

$("#login-btn").click();

HTML

<div style='display:none;'><a href="#login" id='login-btn' data-role="button" data-rel="dialog" >HIDDEN</a></div>

I had this same issue, what I ended up doing was creating a hidden button, then triggering a click event on that button. I know this is probably not the correct way to do it, but I thought I'd offer up a solution/hack. If anyone else has something better I would really like to hear about it.

JS

$("#login-btn").click();

HTML

<div style='display:none;'><a href="#login" id='login-btn' data-role="button" data-rel="dialog" >HIDDEN</a></div>
梨涡少年 2025-01-05 06:11:57

文档松散地引用了 page 对象在这里引用。

所以我认为你会想要这样的东西:

var page = $("#page2");

这可能会回答你的问题,但可能对解决你的问题没有多大作用。有多种方法可以处理此问题,但以下是如何重定向到 pagechange 上的特定页面的示例:http://jsfiddle.net/BD9ax/

希望这有助于解决您的问题。

The docs are referring to the page object loosely referred to here.

So I think you would want something like this:

var page = $("#page2");

That may answer your question, but probably won't do much to solve your problem. There are several ways to handle this, but here is an example of how to redirect to a specific page on pagechange: http://jsfiddle.net/BD9ax/

Hope this helps resolve your issue.

偏爱自由 2025-01-05 06:11:57
// the following args, plus a jQuery collection object
// containing the DOM element for the page.

他们使用 page 来表示额外的参数。例如,

var $page = $('<div data-role="page" data-dom-cache="true">'
    + 'your content'
    + '</div>');
data.options.pageContainer.append($page);
data.deferred.resolve(data.absUrl, data.options, $page);

这是 jQuery Mobile 1.3 的情况。

// the following args, plus a jQuery collection object
// containing the DOM element for the page.

They are using page to denote that extra argument. e.g.

var $page = $('<div data-role="page" data-dom-cache="true">'
    + 'your content'
    + '</div>');
data.options.pageContainer.append($page);
data.deferred.resolve(data.absUrl, data.options, $page);

This is with jQuery Mobile 1.3.

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