【发布时间】:2012-10-03 06:48:55
【问题描述】:
我想在用户向后和向前点击时调用我的控制器。但我无法在 window.onpopstate 中访问我的控制器。我也尝试将我的控制器放入历史状态数据,但它会导致错误。
-
尝试在 onpopstate 中访问我的控制器:
Ext.define('PageController',{ extend:'Ext.app.Controller', onLaunch:function(){ window.onpopstate = this.onPopState; //trigger the onPopState function when backward and forward window.history.pushState(null, '', '/'); }, onPopstate:function(s){ this.someFunction(); //"this" is not PageController, it's PopStateEvent }, someFunction:function(){...} }); -
尝试让我的控制器进入状态:
Ext.define('PageController',{ extend:'Ext.app.Controller', onLaunch:function(){ window.onpopstate = this.onPopState; //trigger the onPopState function when backward and forward window.history.pushState({'controller':this}, '', '/'); //try to put my controller into state data, which causes error }, onPopstate:function(s){ s.state.controller.someFunction(); }, someFunction:function(){...} });
firebug 中的错误: 未捕获的错误:DATA_CLONE_ERR:DOM 异常 25
那么,如何在 window.onpopstate 中访问我的控制器? 或者是否可以在我的控制器中为向后和向前事件添加侦听器?
【问题讨论】:
标签: javascript extjs history