Jquery mobile,如何手动更改;pagebeforeload“;事件
我正在尝试使用文档中定义的方法重定向页面Jquery mobile,如何手动更改;pagebeforeload“;事件,jquery,jquery-mobile,Jquery,Jquery Mobile,我正在尝试使用文档中定义的方法重定向页面 $( 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
$( 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 );
});
但我不确定resolve到底使用了什么参数我在任何地方都找不到文档,那里的页面参数到底是什么?我遇到了同样的问题,我最后做的是创建一个隐藏按钮,然后触发该按钮上的单击事件。我知道这可能不是正确的方法,但我想我应该提供一个解决方案/黑客。如果其他人有更好的,我真的很想听听 JS HTML
文档松散地引用了
页面
对象
所以我想你会想要这样的东西:
var page = $("#page2");
这也许能回答你的问题,但可能对解决你的问题没有多大帮助。有几种方法可以处理此问题,但下面是如何重定向到pagechange
上的特定页面的示例:
希望这有助于解决您的问题
// the following args, plus a jQuery collection object
// containing the DOM element for the page.
他们使用page
来表示额外的参数。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);
var$page=$(“”
+“您的内容”
+ '');
data.options.pageContainer.append($page);
data.deferred.resolve(data.absUrl,data.options,$page);
这是jquerymobile1.3的一个例子。您应该在更改之前在页面上重定向
// the following args, plus a jQuery collection object
// containing the DOM element for the 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);