Search code examples
javascripthtmlyuialloy-ui

Adding a Tab to TabView


In AlloyUI is there a simple way to add a tab to an existing TabView? I've searched the API but could not find a proper example.

Something like:

var tabview = new Y.TabView({
  srcNode: '#myContainer'
 }).render();//main Tab View

var myDynamicTab = new Y.Tab({
  label: 'foo',
  content: 'bar'
});
...
button.on(
  'click',
   function(e){
     tabview.add(myDynamicTab.render(tabview), 2);//adds tab to index 2
     ...

I've checked this example from the YUI API but it seems very involved: http://yuilibrary.com/yui/docs/tabview/tabview-add-remove.html


Solution

  • Turns out my code above nearly accomplished what I needed-this worked fine:

    button.on(
      'click',
      function(e){
         var tab = new Y.Tab({
            label: myObj.title,
            content: myData
         });
         tabview.add(tab, 2);
         ...