Skip to content

Instantly share code, notes, and snippets.

@scottgonzalez
Created May 9, 2011 16:42
Show Gist options
  • Save scottgonzalez/962848 to your computer and use it in GitHub Desktop.
Save scottgonzalez/962848 to your computer and use it in GitHub Desktop.
quick overview of extending jQuery UI widgets in 1.8 and 1.9
(function( $, prototype ) {
$.extend( prototype.options, {
spinner: "<em>Loading&#8230;</em>"
});
var _create = prototype._create;
prototype._create = function() {
_create.call( this );
var self = this;
this.element.bind( "tabsbeforeload", function( event, ui ) {
if ( !self.options.spinner ) {
return;
}
var span = ui.tab.find( "span" ),
html = span.html();
span.html( self.options.spinner );
ui.jqXHR.complete(function() {
span.html( html );
});
});
};
}( jQuery, jQuery.ui.tabs.prototype ) );
$.widget( "ui.tabs", $.ui.tabs, {
options: {
spinner: "<em>Loading&#8230;</em>"
},
_create: function() {
this._super( "_create" );
this._bind({
tabsbeforeload: function( event, ui ) {
if ( !this.options.spinner ) {
return;
}
var span = ui.tab.find( "span" ),
html = span.html();
span.html( this.options.spinner );
ui.jqXHR.complete(function() {
span.html( html );
});
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment