Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle select event of tab widget of jquery ui?

I use tab widget of jquery ui in my webpage The initialization is ok. but want to capture the on_selected event of a tab to do something else. I followed docs of jquery but it does not work. doc!

I have tried

    $( "#editor-tabs" ).tabs();
    $("#editor-tabs").bind("tabsshow",function(event,ui){
            alert(ui.index);
    });

and

$( "#editor-tabs" ).tabs({
    select: function(event,ui){alert(ui.index);}
});

Put breakpoints to the callback function and they are not hit.

like image 618
GingerJim Avatar asked Apr 10 '13 16:04

GingerJim


2 Answers

if you use jquery ui 1.10.* , following code is correct. I used the doc by mistake. It is only for 1.8

Better to check your version number if you got a similar problem.

        $("#editor-tabs" ).tabs({                                                                  
            activate:function(event,ui){                                                       
                            alert(ui.index);                                                   
                    }                                                                          
         });   
like image 72
GingerJim Avatar answered Oct 01 '22 01:10

GingerJim


See my response for this question which is similar:

https://stackoverflow.com/a/17509685/763629

Note for jQuery UI 1.10.x+ use this:

ui.newTab.index()
like image 24
technopia Avatar answered Oct 01 '22 01:10

technopia