Created
May 9, 2011 16:42
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function( $, prototype ) { | |
$.extend( prototype.options, { | |
spinner: "<em>Loading…</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 ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.widget( "ui.tabs", $.ui.tabs, { | |
options: { | |
spinner: "<em>Loading…</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