Solved

Jquery tabs click

Posted on 2011-09-17
8
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

737 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