Solved

Jquery tabs click

Posted on 2011-09-17
8
235 Views
Last Modified: 2012-05-12
Hello.

Please tell me what is wrong here:

$("#featured > ul").bind("tabsselect", function(event, ui) {
  	selectedTab =$("#featured > ul").tabs().data("selected.tabs");
	alert (ui.index);
)}

Open in new window


ui.index is undefined. I need that for click event.

Please Help.
0
Comment
Question by:radugheorghies
  • 4
  • 4
8 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36553683
if ui is the element that is clicked, you can replace it with

alert($(this).index());
0
 

Author Comment

by:radugheorghies
ID: 36553720
Hello gurvinder372

alert($(this).index()) in my fuction is always -1 (for all tabs).
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36553725
okay, tell me one thing

$("#featured > ul").bind("tabsselect", function(event, ui) {
        //selectedTab =$("#featured > ul").tabs().data("selected.tabs");
      //alert (ui.index);
     alert($(this).html());
)}

when you select tab, does this alert the correct tab?
0
 

Author Comment

by:radugheorghies
ID: 36553745
this is what I get on any tab:

            
 <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1"><div class="spatiu1"><a href="#fragment-1"><img src="images/gol.gif" alt="" height="100" width="138"></a></div></li>
	        <li class="ui-tabs-nav-item" id="nav-fragment-2"><div class="spatiu2"><a href="#fragment-2"><img src="images/gol.gif" alt="" height="100" width="138"></a></div></li>
	        <li class="ui-tabs-nav-item" id="nav-fragment-3"><div class="spatiu3"><a href="#fragment-3"><img src="images/gol.gif" alt="" height="100" width="138"></a></div></li>
	        <li class="ui-tabs-nav-item" id="nav-fragment-4"><div class="spatiu4"><a href="#fragment-4"><img src="images/gol.gif" alt="" height="100" width="138"></a></div></li>
            <li class="ui-tabs-nav-item" id="nav-fragment-5"><div class="spatiu5"><a href="#fragment-5"><img src="images/gol.gif" alt="" height="100" width="138"></a></div></li>

Open in new window


This is what alert($(this).html()) is doing.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 36553752
why don't you simply do

alert($(".ui-tabs-selected").index());

since by now you know which one is selected, because .ui-tabs-selected class is attached to it
0
 

Author Comment

by:radugheorghies
ID: 36553801
hmmm.

alert($(".ui-tabs-selected").index()); is always -1.
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36553806
even if you select some other tab also?

In that case, whatever plugin you are using, is not assigning the class properly
0
 

Author Comment

by:radugheorghies
ID: 36553926
i did it in other way:

var mycheckedtab=setInterval("checktabs()",200);

function checktabs(){
	if ($("#nav-fragment-2").hasClass("ui-tabs-selected")){
		$("#fragmentelemele-1").show();
		$("#fragmentelemele-2").hide();
		$("#fragmentelemele-3").hide();
		$("#fragmentelemele-4").hide();
		$("#fragmentelemele-5").hide();	
	}
	
	if ($("#nav-fragment-3").hasClass("ui-tabs-selected")){
		$("#fragmentelemele-1").hide();
		$("#fragmentelemele-2").show();
		$("#fragmentelemele-3").hide();
		$("#fragmentelemele-4").hide();
		$("#fragmentelemele-5").hide();	
	}
	
	if ($("#nav-fragment-4").hasClass("ui-tabs-selected")){
		$("#fragmentelemele-1").hide();
		$("#fragmentelemele-2").hide();
		$("#fragmentelemele-3").show();
		$("#fragmentelemele-4").hide();
		$("#fragmentelemele-5").hide();	
	}
	
	if ($("#nav-fragment-5").hasClass("ui-tabs-selected")){
		$("#fragmentelemele-1").hide();
		$("#fragmentelemele-2").hide();
		$("#fragmentelemele-3").hide();
		$("#fragmentelemele-4").show();
		$("#fragmentelemele-5").hide();	
	}
	if ($("#nav-fragment-1").hasClass("ui-tabs-selected")){
		$("#fragmentelemele-1").hide();
		$("#fragmentelemele-2").hide();
		$("#fragmentelemele-3").hide();
		$("#fragmentelemele-4").hide();
		$("#fragmentelemele-5").show();	
	}
	}

Open in new window


Thanks for suggestion gurvinder372.

I think it is something wrong with jQuery UI.
I am using 1.3.2 version.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
count download link and run update query 9 55
JS Plugin 4 29
JS Plugin Chaining 2 32
Don't understand jquery promises 6 36
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now