[ 5 posts ]

Chongo

  • Username: Chongo
  • Joined: Mon Dec 12, 2011 6:42 am
  • Posts: 4
  • Offline
  • Profile

TabView - how to change an existing tab's dataSrc

Post Posted: Mon Dec 12, 2011 6:54 am
+0-
I've looked all over for an answer to this question but have been unable to find one.

Utilizing a basic set of tabs that has been previously loaded with ajax content, how do I go about changing the existing dataSrc on a tab with a different dataSrc? I'd like to be able to page through records already displayed in a tab, which would require a change to the existing data source URL and I can't seem to find how you go about calling this within the framework.

For instance, using the following sample tabs, how would I change via script the URL for loaded tab #2 to
'/test/page.htm?id=2&page=2'?

var tabView = new YAHOO.widget.TabView();

function tabs(){
tabView.addTab( new YAHOO.widget.Tab({
label: 'First Tab'
dataSrc: '/test/page.htm?id=1',
cacheData: true,
active: true
}));
tabView.addTab( new YAHOO.widget.Tab({
label: 'Second Tab',
dataSrc: '/test/page.htm?id=2',
cacheData: true
}));
tabView.addTab( new YAHOO.widget.Tab({
label: 'Third Tab',
dataSrc: '/test/page.htm?id=3',
cacheData: true
}));
tabView.addTab( new YAHOO.widget.Tab({
label: 'Fourth Tab',
dataSrc: '/test/page.htm?id=4',
cacheData: true
}));
tabView.appendTo('container');
}
window.onload = tabs;


Thanks in advance for any help folks can give me

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile

Re: TabView - how to change an existing tab's dataSrc

Post Posted: Mon Dec 12, 2011 8:23 am
+0-
You can use the `getTab` method on the TabView to get the tab:
http://developer.yahoo.com/yui/docs/YAH ... hod_getTab

Code:
var tab = tabView.getTab(1); //Indexes start at 0, so 1 is the second tab
tab.set('dataSrc', '/my/new/url?here=1');

Chongo

  • Username: Chongo
  • Joined: Mon Dec 12, 2011 6:42 am
  • Posts: 4
  • Offline
  • Profile
Tags:

Re: TabView - how to change an existing tab's dataSrc

Post Posted: Mon Dec 12, 2011 9:59 am
+0-
You sir, rule.

I knew it would be something simple.

Thanks tons!

Chongo

  • Username: Chongo
  • Joined: Mon Dec 12, 2011 6:42 am
  • Posts: 4
  • Offline
  • Profile
Tags:

Re: TabView - how to change an existing tab's dataSrc

Post Posted: Mon Dec 12, 2011 10:30 am
+0-
OK - getting close :)

Additional function added for dynamic alteration:

function tabLink(tabcont,id,url) {
var tab = eval(tabcont + '.getTab(' + id + ')');
tab.set('dataSrc', url);
}

I see that it changes the dataSrc - but it requires clicking on the tab itself to reload the tab with the new dataSrc - what is the call to reload the tab (as if I clicked on it to load the dataSrc)?

Thanks again for your help, I really appreciate it!

Chongo

  • Username: Chongo
  • Joined: Mon Dec 12, 2011 6:42 am
  • Posts: 4
  • Offline
  • Profile

Re: TabView - how to change an existing tab's dataSrc

Post Posted: Mon Dec 12, 2011 10:35 am
+0-
And, I've answered my own question - I can call selectTab and restore.

Thanks much again for your help!
  [ 5 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum