Thank you for reporting this bug. We will make it our priority to review this report.
Changing hash before launch causes action to be called twice
Changing hash before launch causes action to be called twice
Example controller which attempts to change the hash before launch occurs and routing is called.
Code:
/**
* The main application controller. This is a good place to handle things like routes.
*/
Ext.define('app.controller.Root', {
extend: 'Ext.app.Controller',
requires: [
'Ext.util.History'
],
init: function() {
var history = Ext.util.History,
currentHash = history.getHash();
if (app.model.Member.isLoggedIn()) {
} else if (currentHash.indexOf('login') !== 0) {
// Both of these result in a double call because of the hashchange event.
// history.setHash('login/' + history.getHash());
this.getApplication().redirectTo('login/' + history.getHash());
}
}
});
Fix for Ext.util.History.handleStateChangeCode:
/**
* Fix for handleStateChange to chekcing if the currentToken is different than token before proceeding.
* Added a 'force' property as well so that handleStateChange could still continue if 'force' === true.
*/
Ext.define('app.util.History', {
override: 'Ext.util.History',
/**
* Handles when the hash in the URL has been updated. Will also fired the change event.
*
* @param {String} token The token that was changed to
* @private
*/
handleStateChange: function(token, force) {
if (this.currentToken !== token || force === true) {
this.callParent(arguments);
}
}
});
vendredi 6 juin 2014
Changing hash before launch causes action to be called twice
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire