/** * @author Ed Spencer * @private * * Manages the stack of {@link Ext.app.Action} instances that have been decoded, pushes new urls into the browser's * location object and listens for changes in url, firing the {@link #change} event when a change is detected. * * This is tied to an {@link Ext.app.Application Application} instance. The Application performs all of the * interactions with the History object, no additional integration should be required. */ Ext.define('Ext.app.History', { mixins: ['Ext.mixin.Observable'], /** * @event change * Fires when a change in browser url is detected * @param {String} url The new url, after the hash (e.g. http://myapp.com/#someUrl returns 'someUrl') */ config: { /** * @cfg {Array} actions The stack of {@link Ext.app.Action action} instances that have occurred so far */ actions: [], /** * @cfg {Boolean} updateUrl `true` to automatically update the browser's url when {@link #add} is called. */ updateUrl: true, /** * @cfg {String} token The current token as read from the browser's location object. */ token: '' }, constructor: function(config) { if (Ext.feature.has.History) { window.addEventListener('hashchange', Ext.bind(this.detectStateChange, this)); } else { this.setToken(window.location.hash.substr(1)); setInterval(Ext.bind(this.detectStateChange, this), 100); // 定时监听 url 变化, 生成action 完成路由跳转 //window.location.hash 真是html5 的好东西呀!!! } this.initConfig(config); }, /** * Adds an {@link Ext.app.Action Action} to the stack, optionally updating the browser's url and firing the * {@link #change} event. * @param {Ext.app.Action} action The Action to add to the stack. * @param {Boolean} silent Cancels the firing of the {@link #change} event if `true`. */ add: function(action, silent) { this.getActions().push(Ext.factory(action, Ext.app.Action)); var url = action.getUrl(); if (this.getUpdateUrl()) { // history.pushState({}, action.getTitle(), "#" + action.getUrl()); this.setToken(url); window.location.hash = url; } if (silent !== true) { this.fireEvent('change', url); } this.setToken(url); }, /** * Navigate to the previous active action. This changes the page url. */ back: function() { var actions = this.getActions(), previousAction = actions[actions.length - 2], app = previousAction.getController().getApplication(); actions.pop(); app.redirectTo(previousAction.getUrl()); }, /** * @private */ applyToken: function(token) { return token[0] == '#' ? token.substr(1) : token; }, /** * @private */ detectStateChange: function() { var newToken = this.applyToken(window.location.hash), oldToken = this.getToken(); if (newToken != oldToken) { this.onStateChange(); this.setToken(newToken); } }, /** * @private */ onStateChange: function() { this.fireEvent('change', window.location.hash.substr(1)); } });
详细解决方案
Sencha Touch history 了解
热度:1030 发布时间:2013-02-24 17:58:56.0
相关解决方案
- Iframe top.history.go(@Num)有关问题
- 请问后退按纽(history.go(-1))的有关问题
- history.go(-1),返回上一頁時出現網頁過期,謝謝,该怎么处理
- Response.Write("<script language='javascript' type='text/javascript'>history.back()</script>")
- 返回前一頁面的問題:Button1.Attributes.Add("onclick" "history.go(-1);return false;");無效。该怎么解决
- 高端ERP市场三国争霸,Touch 用友U9的世界级,该怎么解决
- 高端ERP市场三国争霸,Touch 用友U9的世界级,该如何解决
- (44)I just bought a new touch phone online, I'm in raptures.该怎么解决
- (44)I just bought a new touch phone online, I'm in raptures.解决方法
- get in touch with please解决方案
- history.back后退至上一页,遮罩层div无法消除的有关问题
- Sencha Touch加载远道Html
- html,jsp返回下一页 history.go(-1)网页过期
- 操纵历史,利用HTML5 History API兑现无刷新跳转
- 运用Sencha Touch 2MVC框架内嵌html开发
- sencha 2.0 基于HTML5的sessionstorage的运用
- Sencha Touch 二 获取 html img 标签
- 解决sencha touch 2 AJAX提交中文乱码有关问题
- sencha touch设立延迟执行
- history.go(-一)和History.back(-1)的区别
- Sencha Touch API 汉语(1)
- sencha touch 设立mask时间
- (一)前言――(10)jquery项目的历史(History of the jQuery project)
- Sencha Touch history 了解
- webView 组合js 获取 touch 坐标
- Sencha Touch 判断反正屏
- 挪动框架介绍之Sencha Touch
- Sencha Touch 二 第一讲
- history.back()丢失会话数据的解决方法
- Sencha touch 二通过Ext.ComponentQuery.query查找组件