Skip to main content

Search and Top Navigation

#8213 closed feature (wontfix)

Opened March 23, 2012 10:57AM UTC

Closed March 23, 2012 11:50AM UTC

finding tab by title

Reported by: mdibbets Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.tabs Version: 1.8.18
Keywords: Cc:
Blocked by: Blocking:
Description

I have made a function that can make it possible to find the index of a certain tab.

ispresent:function(a,b)
	{
	//a = string searchquery
	//b = be case sensitive or not. 'casesensitive' is yes, 'caseinsensitive' is no. Default is no
	//c = index location of of the tab if found. default is -1 and means not found.
	//d = [for loop]string with value of the tab title stripped of all html tags.
	//e = boolean with the result of b.
	//i = for loop iterator.
	var c=-1;
	var e=false;
	if(typeof b != 'undefined')
		{
		switch(b)
			{
			case 'casesensitive':e=true;break;
			case 'caseinsensitive':e=false;a=a.toLowerCase();break;
			default: e=false;break;
			}
		}
	if(typeof a != 'undefined')
		{		
		for(var i = 0; i < $(this.lis).length; i++)
			{
			var d = $(this.lis).eq(i).find("a").html().replace(/(<([^>]+)>)/ig,"");
			if(!e)d=d.toLowerCase();
			if(d==a)
				{
				c = i;
				break;
				}
			else
				{
				c=-1;
				}
			}
		}
	return c;
	}

I'm using this myself to be able to find tabs that my php editor tool has generated, so that I don't open the same tab twice.

This function returns the index of the tab found with the exact title. Options are available for case sensitivity.

It works wonderfully on my code in different browsers.

Useage example:

window.alert($('#tabs').tabs().tabs('ispresent','Articles to edit','casesensitive'));

I bet you guys can improve my code in someway, but I know that a lot of people are dying for a feature like this.

Attachments (0)
Change History (1)

Changed March 23, 2012 11:50AM UTC by scottgonzalez comment:1

resolution: → wontfix
status: newclosed

We already have two methods for finding tabs, we're not adding more. Build this as an extension.