How to handle selected jquery ui tab widget event?

I am using the jquery ui tab widget on my Initialization webpage in order. but want to capture the on_selected event in a tab to do something else. I followed the jquery docs but that didn't work. doc !

I 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 on the callback function and they are not affected.

+5
source share
3 answers

if you are using jquery ui 1.10. *, the following code is correct. I used the doc error by mistake. Only for 1.8

It is better to check the version number if you have a similar problem.

        $("#editor-tabs" ).tabs({                                                                  
            activate:function(event,ui){                                                       
                            alert(ui.index);                                                   
                    }                                                                          
         });   
+9
source

See my answer to this question, similar:

fooobar.com/questions/1125324/...

jQuery UI 1.10.x + :

ui.newTab.index()
+7

Could you post some sample code? According to http://api.jqueryui.com/tabs/ therer is not an "on_selected" event, but it fires, beforeActivate, beforeLoad, creates and loads.

And what goal do you want to achieve?

Perhaps refer to this: jQuery - targeting selection event

 $('#tabs, #fragment-1').tabs({
  select: function(event, ui){
    // Do stuff here
  }
});
0
source

All Articles