View Full Version : [OPEN-1149] History.getToken returns not current hash directly after setting token

21 Jul 2010, 6:14 AM
After a component has changed the history I would like to access the history from another component. Is it right that you get the old value from history?

If you add the log in history.js you will see that after adding the token you can't read the current token by Ext.History.getToken

listeners: {
'tabchange': function(tabPanel, tab){
// Ignore tab1 since it is a separate tab panel and we're managing history for it also.
// We'll use its handler instead in that case so we don't get duplicate nav events for sub tabs.
if(tab.id != 'tab1'){
Ext.History.add(tabPanel.id + tokenDelimiter + tab.id);
console.log(tabPanel.id + tokenDelimiter + tab.id, Ext.History.getToken());
Thanks in advance.

21 Jul 2010, 10:20 AM
Do you consider this a bug? I could move it to bugs forum if yes.

22 Jul 2010, 1:22 AM
I don't know if it is a bug. Perhaps it works this way on purpose. However, my first thought was a bug. If I set the token I would expect to get this value afterwards.

22 Jul 2010, 2:40 AM
And doesn't docs clearly describe this behavior? It can be an inaccuracy/bug in docs...

22 Jul 2010, 5:05 AM
No, not clearly at all! Here an extract from the docs

add (http://www.sencha.com/deploy/dev/docs/source/History.html#method-Ext.History-add)( String token, Boolean preventDuplicates ) : voidAdd a new token to the history stack. This can be any arbitrary value, ...

getToken (http://www.sencha.com/deploy/dev/docs/source/History.html#method-Ext.History-getToken)() : StringRetrieves the currently-active history token.

IMHO, adding a new token to the history stack would it make the currently-active token because this is the one I see in browsers address bar.

22 Jul 2010, 12:18 PM
OK, I'm moving the thread to bugs for the devel team to look at it and either fix it or explain it.

Jamie Avins
23 Jul 2010, 9:01 AM
I can speculate that since history is what was in the past it doesn't include the present state. I agree the documentation needs to clearly state this.