Yii Framework Forum: Change Ctabview Active Tab With Link Or Button - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Change Ctabview Active Tab With Link Or Button Change CTabView active tab with Link or Button Rate Topic: -----

#1 User is offline   willbelair 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 08-April 11

Posted 08 January 2013 - 10:49 AM

Hi,
I was searching for help with click on link or button to change the active tab. I came across this thread My link , but it did not work for me. Then I figured out that with just a simple function, either you hard code the tab number, or passing the #tabx to the function, it works fine. And I just want to share in case someone else needs. Thanks all. How to use: just put the script anywhere on tab page, add link or button with onclick='changetab()'

<script>
	function changetab(){
                // PLEASE NOTE THIS IS NOT ADDING NEW TAB, IT JUST ACTIVATES #tab4
                // var id = tabnumber;
		var id = '#tab4';
		var pos = id.indexOf("#");
		if (pos>=0) {
			id = id.substring(pos);
		}
		var $tab=$(id);
		var $container=$tab.parent();
		$container.find('>ul a').removeClass('active');
		$container.find('>ul a[href="'+id+'"]').addClass('active');
		$container.children('div').hide();
		$tab.show();

		// you also can add new content to the tab by setting     
                // document.getElementById('mytab').innerHTML
         }       

</script>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users