我正在尝试使用文档中定义的方法重定向页面
$( 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 );
});
但我不确定params究竟解决了什么问题我无法在任何地方找到文档,那里的页面参数究竟是什么?
答案 0 :(得分:0)
我有同样的问题,我最终做的是创建一个隐藏按钮,然后触发该按钮上的点击事件。我知道这可能不是正确的方法,但我认为我会提供一个解决方案/黑客。如果其他人有更好的东西,我真的很想听听。
JS
$("#login-btn").click();
HTML
<div style='display:none;'><a href="#login" id='login-btn' data-role="button" data-rel="dialog" >HIDDEN</a></div>
答案 1 :(得分:0)
文档松散地引用page
对象referred to here。
所以我认为你会想要这样的东西:
var page = $("#page2");
这可能会回答您的问题,但可能无法解决您的问题。有几种方法可以解决此问题,但以下是如何重定向到pagechange
上的特定页面的示例:http://jsfiddle.net/BD9ax/
希望这有助于解决您的问题。
答案 2 :(得分:0)
// 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);
这是jQuery Mobile 1.3。