PDA

View Full Version : History management example when opeing in a new window is not working in Firefox



url
12 Apr 2013, 6:56 AM
Hi All,
My requirement is to show the o/p of History management in a new window.
For this i have written the code like this:



top.consoleRef= window.open('','newwindow');
top.consoleRef.document.writeln( update );
top.consoleRef.document.close();


Where the variable "update" contains the History management code provided by Extjs in a string format.
sample History management code :


Ext.onReady(function() {

Ext.History.init();

var tokenDelimiter = ':';

function onTabChange(tabPanel, tab) {
var tabs = [],
ownerCt = tabPanel.ownerCt,
oldToken, newToken;

tabs.push(tab.id);
tabs.push(tabPanel.id);

while (ownerCt && ownerCt.is('tabpanel')) {
tabs.push(ownerCt.id);
ownerCt = ownerCt.ownerCt;
}

newToken = tabs.reverse().join(tokenDelimiter);

oldToken = Ext.History.getToken();

if (oldToken === null || oldToken.search(newToken) === -1) {
Ext.History.add(newToken);
}
}

// Handle this change event in order to restore the UI to the appropriate history state
function onAfterRender() {
Ext.History.on('change', function(token) {
var parts, tabPanel, length, i;

if (token) {
parts = token.split(tokenDelimiter);
length = parts.length;

// setActiveTab in all nested tabs
for (i = 0; i < length - 1; i++) {
Ext.getCmp(parts[i]).setActiveTab(Ext.getCmp(parts[i + 1]));
}
}
});

// This is the initial default state. Necessary if you navigate starting from the
// page without any existing history token params and go back to the start state.
var activeTab1 = Ext.getCmp('main-tabs').getActiveTab(),
activeTab2 = activeTab1.getActiveTab();

onTabChange(activeTab1, activeTab2);
}

Ext.create('Ext.TabPanel', {
renderTo: Ext.getBody(),
id: 'main-tabs',
height: 300,
width: 600,
activeTab: 0,
defaults: {
padding: 10
},

items: [{
xtype: 'tabpanel',
title: 'Tab 1',
id: 'tab1',
activeTab: 0,
padding: 5,
border: true,
plain: true,

defaults: {
padding: 10
},

items: [{
title: 'Sub-tab 1',
id: 'subtab1',
html: 'Sub-tab 1 content'
},{
title: 'Sub-tab 2',
id: 'subtab2',
html: 'Sub-tab 2 content'
},{
title: 'Sub-tab 3',
id: 'subtab3',
html: 'Sub-tab 3 content'
}],

listeners: {
tabchange: onTabChange
}
},{
title: 'Tab 2',
id: 'tab2',
html: 'Tab 2 content'
},{
title: 'Tab 3',
id: 'tab3',
html: 'Tab 3 content'
},{
title: 'Tab 4',
id: 'tab4',
html: 'Tab 4 content'
},{
title: 'Tab 5',
id: 'tab5',
html: 'Tab 5 content'
}],
listeners: {
tabchange: onTabChange,
afterrender: onAfterRender
}
});
});


after executing this example it is redirecting to my original application.
I found that the problem is happening due to Ext.History.add(newToken); , by commenting this line the url is not redirecting and the History also not maintaining.


Can anybody plaese suggest what i need to do inorder to achieve this in Firefox


Thanks
Url

slemmon
15 Apr 2013, 9:45 AM
I'm sorry, but I'm not yet following what you're wanting to do. Not sure what "the o/p of History management" is.

Can you elablorate?

Also, please wrap your code in [ ] code tags for readability.