Loading ...
Sorry, an error occurred while loading the content.

Re: Tab already exists ... (global unique ID for each tab)

Expand Messages
  • Caridy Patiño Mayea
    Hi Prasanna, Sorry for the delay... Unfortunately, the tabview/tab control don t have a manager to interconnect the DOM references with a certain tabview/tab
    Message 1 of 4 , Sep 1, 2007
    • 0 Attachment
      Hi Prasanna,

      Sorry for the delay...

      Unfortunately, the tabview/tab control don't have a manager to
      interconnect the DOM references with a certain tabview/tab object,
      just like the YUI MenuManager control...

      Will be great if the YUI's guys include something like this:

      YAHOO.widget.TabviewManager.getTab ('mytab1');
      YAHOO.widget.TabviewManager.getTabView ('mytabview1');

      Don't you think so?

      Well, getting back to your problem, You have few possible solutions here:

      1. Based on the previous example... just find the position of the LI
      with the correct ID (equal to guid), and based on this position, apply
      the correct activeIndex for the tabview.

      2. Create a hash table (a literal object) to store the references of
      each tab, based on the guid, and then you can use this reference to
      activate the tab.

      That's all..

      Best Regards,
      Caridy (caridy at gmail.com)
      http://www.bubbling-library.com/


      --- In ydn-javascript@yahoogroups.com, "Nagasamudram, Prasanna Kumar"
      <prasanna.nagasamudram@...> wrote:
      >
      > Hi Caridy
      >
      >
      >
      > Thanks that worked.
      >
      >
      >
      > My next question would be instead of alert("Already exists"), can I
      make that tab as the active tab ?
      >
      >
      >
      > For example instead of saying tab1 already exists, the control
      should just go to the tab1(I mean tab1 should be on the top now).
      >
      >
      >
      > How do I get the pointer to the tab with id guid ?
      >
      >
      >
      >
      >
      >
      >
      > Thanks
      >
      > Prasanna
      >
      >
      >
      >
      >
      > ________________________________
      >
      > From: ydn-javascript@yahoogroups.com
      [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Caridy Patiño Mayea
      > Sent: Thursday, August 30, 2007 10:39 PM
      > To: ydn-javascript@yahoogroups.com
      > Subject: [ydn-javascript] Re: Tab already exists ... (global unique
      ID for each tab)
      >
      >
      >
      > Hi Prasanna,
      >
      > Use a global unique ID for each tab:
      >
      > function addTab(title, text, guid) {
      > if (!YAHOO.util.Dom.inDocument(guid)) {
      > // do your stuff here...
      > .....
      > // add the guid to the tab
      > tab.labelEl.id = guid;
      > return tab;
      > }
      > return null;
      > }
      >
      > Link1.onclick {
      > if (!addTab("new tab title", "new tab text", "mytab1guid")) {
      > alert("Already exists");
      > }
      > }
      >
      > PD: I never tested it, but should work...
      >
      > Best Regards,
      > Caridy (caridy at gmail.com)
      > http://www.bubbling-library.com/ <http://www.bubbling-library.com/>
      >
      > --- In ydn-javascript@yahoogroups.com
      <mailto:ydn-javascript%40yahoogroups.com> , "Nagasamudram, Prasanna Kumar"
      > <prasanna.nagasamudram@> wrote:
      > >
      > > Hi All
      > >
      > >
      > >
      > > How does one know that the tab already exists ?
      > >
      > >
      > >
      > > For Eg :
      > >
      > >
      > >
      > > I have three links
      > >
      > >
      > >
      > > Link1 , Link2 and Link3
      > >
      > >
      > >
      > > Clicking on which a new tab opens.
      > >
      > >
      > >
      > > But when I click on Link1 for the second, I should get an alert saying
      > > that the tab already exists..
      > >
      > >
      > >
      > > I have the following logic...
      > >
      > >
      > >
      > > function addTab(title, text)
      > >
      > > {
      > >
      > > if(!window.tabView)
      > >
      > > {
      > >
      > > tabView = new YAHOO.widget.TabView( { id: 'demo' } );
      > >
      > > tabView.appendTo('tabContainer');
      > >
      > > }
      > >
      > > tab = new YAHOO.widget.Tab({
      > >
      > > label: title,
      > >
      > > content: '',
      > >
      > > active: true
      > >
      > > });
      > >
      > > tabView.addTab( tab );
      > >
      > >
      > >
      > > YAHOO.util.Dispatcher.process( tab, text, {action: 'tabview'} );
      > >
      > >
      > >
      > > return tab;
      > >
      > >
      > >
      > >
      > >
      > > }
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > > Link1.onclick
      > >
      > > {
      > >
      > > If window.T1
      > >
      > > Alert(Already exists);
      > >
      > > else
      > >
      > > T1 = addTab("T1", "Hello T1");
      > >
      > > }
      > >
      > >
      > >
      > > But suppose tab T1 is closed and then the Link1 is clicked then
      still i
      > > will get the, "already exists message.
      > >
      > >
      > >
      > > How do I remove the T1 variable when I close the tab ?
      > >
      > >
      > >
      > > Thanks
      > >
      > > Prasanna
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.