var tabs_defaults = {
activate: null,
beforeload: null,
+ beforeActivate: null,
collapsible: false,
cookie: null,
disabled: false,
event: "click",
fx: null,
- load: null,
- select: null
+ load: null
};
// FAIL: falsy values break the cookie option
add: null,
ajaxOptions: null,
beforeload: null,
+ beforeActivate: null,
cache: false,
collapsible: false,
cookie: null,
});
+test('select', function() {
+ expect(7);
+
+ var eventObj;
+ el = $('#tabs1').tabs({
+ select: function(event, ui) {
+ ok(true, 'select triggered after initialization');
+ equals(this, el[0], "context of callback");
+ equals(event.type, 'tabsselect', 'event type in callback');
+ equals(ui.tab, el.find('a')[1], 'contain tab as DOM anchor element');
+ equals(ui.panel, el.find('div')[1], 'contain panel as DOM div element');
+ equals(ui.index, 1, 'contain index');
+ evenObj = event;
+ }
+ });
+ el.tabs('select', 1);
+
+ el.find( "li:eq(1) a" ).simulate( "click" );
+ equals( evenObj.originalEvent.type, "click", "select triggered by click" );
+});
+
module("tabs (deprecated): methods");
test('add', function() {
module("tabs: events");
-test('select', function() {
+test('beforeActivate', function() {
expect(7);
var eventObj;
el = $('#tabs1').tabs({
- select: function(event, ui) {
- ok(true, 'select triggered after initialization');
+ beforeActivate: function(event, ui) {
+ ok(true, 'beforeActivate triggered after initialization');
equals(this, el[0], "context of callback");
- equals(event.type, 'tabsselect', 'event type in callback');
+ equals(event.type, 'tabsbeforeactivate', 'event type in callback');
equals(ui.tab, el.find('a')[1], 'contain tab as DOM anchor element');
equals(ui.panel, el.find('div')[1], 'contain panel as DOM div element');
equals(ui.index, 1, 'contain index');
el.tabs('select', 1);
el.find( "li:eq(1) a" ).simulate( "click" );
- equals( evenObj.originalEvent.type, "click", "select triggered by click" );
+ equals( evenObj.originalEvent.type, "click", "beforeActivate triggered by click" );
});
test('beforeload', function() {
options: {
activate: null,
beforeload: null,
+ beforeActivate: null,
cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
collapsible: false,
disabled: false,
event: "click",
fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
- load: null,
- select: null
+ load: null
},
_create: function() {
$li.hasClass( "ui-state-disabled" ) ||
// tab is already loading
$li.hasClass( "ui-state-processing" ) ||
- // allow canceling by select event
- self._trigger( "select", event, self._ui( el, $show[ 0 ] ) ) === false ) {
+ // allow canceling by beforeActivate event
+ self._trigger( "beforeActivate", event, self._ui( el, $show[ 0 ] ) ) === false ) {
el.blur();
return;
}
};
}( jQuery, jQuery.ui.tabs.prototype ) );
- // show event
+ // show and select event
(function( $, prototype ) {
$.extend( prototype.options, {
- show: null
+ show: null,
+ select: null
});
var _trigger = prototype._trigger;
if ( !ret ) {
return false;
}
- if ( type === "activate" ) {
+ if ( type === "beforeActivate" ) {
+ ret = _trigger.call( this, "select", event, data );
+ } else if ( type === "activate" ) {
ret = _trigger.call( this, "show", event, data );
}
};