[ 4 posts ]

Steve Kapp

  • Username: Steve Kapp
  • Joined: Tue Jun 16, 2009 7:53 am
  • Posts: 2
  • Offline
  • Profile
Tags:

dynamically updating a tab's datasrc

Post Posted: Tue Jun 16, 2009 8:07 am
+0-
I have a problem with programmatically updating a tab's datasrc . In a nutshell, I am using the YAHOO.plugin.Dispatcher to dynamically load my non-cachable tabs, and each tab has a CGI as its underlying datasrc. I'd like to be able to dynamically update the datasrc before moving from one tab to the next - i.e. catching one of the tab change events and adjusting the datasrc for the soon to be active tab.

I've tried the following code:

Code:
    var tabView = new YAHOO.widget.TabView({id: 'myTabView'});
    // tabs added here
    tabView.subscribe('beforeActiveIndexChange',function (e) {
        var newTabIndex = e.newValue;
        var newTab = tabView.getTab(newTabIndex);
        var newDS= newTab.get('dataSrc');
        newDS += "?foo=bar";
        newTab.set('dataSrc', newDS);
        var ds1 = newTab.get('dataSrc');
        console.log("ds1: " + ds1);
        return true;
    });   

The console log shows that the datasrc has indeed changed, but the old datasrc is still used for the actual HTTP request?

Anybody have an idea of what I am doing wrong?

Regards,

Steve

Caridy Patino

YUI Contributor

  • Username: caridy
  • Joined: Mon Dec 08, 2008 5:40 pm
  • Posts: 494
  • Location: Miami, FL
  • Twitter: caridy
  • GitHub: caridy
  • Gists: caridy
  • IRC: caridy
  • YUI Developer
  • Offline
  • Profile

Re: dynamically updating a tab's datasrc

Post Posted: Tue Jun 16, 2009 1:45 pm
+0-
Hello Steve,

You have two options:

1 - You can turn on cache for tab, and you will be able to change the src. This is because the tab uses a property called "dataLoaded" to keep track of the loading process for non-cachable tabs, and this property is defined as "writeOnce". Even if you change the value of dataSrc, dataLoaded will be true after the first loading process, and it will never load the content again, no matter what.

2 - You can use the dispatcher directly to load the content for the tab. So, you can define the tab without dataSrc, and use dispatcher.fetch to load the content of the tab. Something like this:
Code:
    var tabView = new YAHOO.widget.TabView({id: 'myTabView'});
    // tabs added here
    tabView.subscribe('beforeActiveIndexChange',function (e) {
        var newTabIndex = e.newValue;
        var newTab = tabView.getTab(newTabIndex);
        YAHOO.plugin.Dispatcher.fetch (newTab.get('contentEl'), url, {/* more dispatcher config here */});       
        return true;
    });   


Best Regards,
Caridy

Steve Kapp

  • Username: Steve Kapp
  • Joined: Tue Jun 16, 2009 7:53 am
  • Posts: 2
  • Offline
  • Profile

Re: dynamically updating a tab's datasrc

Post Posted: Wed Jun 17, 2009 5:17 am
+0-
Thanks, Caridy. I will try this out today.

Regards,

Steve

Zeeshan Jan

  • Username: janzeeshan
  • Joined: Wed Jun 20, 2012 2:12 am
  • Posts: 2
  • Offline
  • Profile

Re: dynamically updating a tab's datasrc

Post Posted: Wed Jun 20, 2012 5:45 pm
+0-
Hello Caridy,

I am facing this issue can u suggest a way out:

I have been trying for the complete day to fix this issue:

I have implemented the Yahoo Tab View from existing HTML, I do not require to load the tabs dynamically. Hence I have used to very simple Yahoo TabView using Yahoo APIs 3.5.1

However inside the first tab div I have a div on which I have implemented tooltip feature using jquery also I have the autocomplete text box using jquery.

Both of them do not work when inside the tab , if I place them outside of the tab view control they work fine.

Can any body suggest me how shld I fix this issue.
  [ 4 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