jQuery UI 1.11 and Tabs Link

In Uncategorized by thindery

We had a unique issue with jQuery UI and the tab functionality. Since jQuery UI 1.11 has been released, the API only allows revealing of tabs by the tab index, not the tab ID. This is a huge issue because now it’s more difficult for a page link to automatically open a tab. But we got a solution put together. Check this out!

 

 function id2Index(tabsId, srcId)
 {
 var index=-1;
 var i = 0, tbH = jQuery(tabsId).find("li a");
 var lntb=tbH.length;
 if(lntb>0){
 for(i=0;i<lntb;i++){
 o=tbH[i];
 if(o.href.search(srcId)>0){
 index=i;
 }
 }
 }
 return index;
 }

 

And then you can use this in any link, for example:

jQuery('.open-tab').click(function (event) {
 jQuery("#tabid").tabs("option","active", id2Index("#tabid",jQuery(this).attr('href')));
 });

Comments

comments