Pages

Wednesday, April 25, 2012

Ext Replace History

You can use Ext.History.add() to change the URL bar and add an item to the browser's history. For example, you could go from example.com#contacts to example.com#email

This doesn't reload the page, but you can listen for the change and load different forms in Ext, for example

Today, however, I needed to change the URL without adding an item to History, yet still fire the Ext.History.change event. To do that call:

window.location.replace('#somevalue');

I added a function to Ext.History:

Ext.History.replace = function(value){

    location.replace('#' + value);
};

You might want to use this to go from contacts/create to contacts/99 (say it autosaved), without the using having to hit back twice to get back to where they came from. 

No comments:

Post a Comment