PDA

View Full Version : getting a tabs id



jason_memory
29 Nov 2007, 3:45 PM
When a user clicks a link inside the tab, I need to get the tab Id for the tab that contains the link.

Once I get the tab id I plan on using something like:

tabId.update({url: 'the clicked links url'}); to load the link inside the same tab it was clicked in.

Any help?

jason_memory
29 Nov 2007, 4:54 PM
function reloadTab(e) {
e.preventDefault();
// get the id of the link clicked
var appId = Ext.get(e.target).id;
// get the tabs id that we are in
var tabId = Ext.getCmp('tabPanel').getActiveTab();
// get the href of the link clicked
var appUrl = document.getElementById(appId).href;

// update the tab with the links url
var updater = tabId.getUpdater();
updater.update({
url: appUrl
})
}


Now I just need to find a better way to initiate the realoadTab function. I want it to run whenever a link is clicked in a tab. All I have right now is below. And this will definately not work. How can I get the event to trigger only on 'a tags' in a specified div?


Ext.EventManager.on('center', 'click', reloadTab);