I am trying to detect when a new tab on my jQueryui tab component is clicked. I have followed several guides and blogs, but can't wrap my head around the process. I have the following:
$('#tabs').tabs({
select: function(event,ui) {
alert('selected');
return false;
},
});
I don't know what I'm missing, but the alert never fires. I'm am not strong with jQuery so I'm probably making a stupid mistake, so any help will be appreciated.
Thanks, Kris
Update: jsfiddle example http://jsfiddle.net/T7czp/16/
Latest version use
Are you getting any errors? The trailing
,
after yourselect
will break the script in some browsers.This works as seen in this fiddle: http://jsfiddle.net/T7czp/15/
jquery UI seems to have changed slightly since the last accepted answer.
The ui parameter defined in teh activate function is now an object that looks similar to this:
Object { oldTab={...}, oldPanel={...}, newTab={...}, more...}
The index method is inside each of these. So the updated access method is:
@Kristofer
You code is correct.
The only thing you must remove in order to the tab get selected is the line:
because according with the Tabs component documentation:
(the "tabselect" event corresponds to the "select" handler)
You need to bind the event to the tab.