后取消绑定事件我想,当我改变页面取消绑定的所有事件。我把this solution与this.unbind()调用扩展视图的关闭功能,我试图把它与JQM页面过渡在changePage功能的路由器从here结合:骨干和jQuery Mobile的:一个页面过渡
changePage: function(page){
$(page.el).attr("data-role", "page");
page.render();
$("body").append($(page.el));
var transition = $.mobile.defaultPageTransition;
if(this.firstPage){
transition = "none",
this.firstPage = false;
}
$.mobile.changePage($(page.el), {changeHash: false, transition: transition});
}
然后changePage看起来是这样的:
changePage: function(page){
if (this.currentView)
this.currentView.close();
$(page.el).attr("data-role", "page");
this.currentView = page;
page.render();
$("body").append($(page.el));
var transition = $.mobile.defaultPageTransition;
if(this.firstPage){
transition = "none",
this.firstPage = false;
}
$.mobile.changePage($(page.el), {changeHash: false, transition: transition});
}
但后来我得到的JQM错误:
Uncaught TypeError: Cannot call method '_trigger' of undefined jquery.mobile-1.1.0.js:2788
transitionPages jquery.mobile-1.1.0.js:2788
$.mobile.changePage jquery.mobile-1.1.0.js:3390
window.AppRouter.Backbone.Router.extend.changePage
我也有JQM-config.js其删除页面的DOM上pagehide甚至吨。我可以解除所有事件:$(event.currentTarget).unbind();
?但是这也行不通。
$('div[data-role="page"]').live('pagehide', function (event, ui) {
$(event.currentTarget).remove();
});