-jQuery.fn.extend({
- // TODO: make bind(), unbind() and one() DRY!
- bind: function( type, data, fn, thisObject ) {
- // Handle object literals
- if ( typeof type === "object" ) {
- for ( var key in type ) {
- this.bind(key, data, type[key], fn);
- }
- return this;
- }
-
- if ( jQuery.isFunction( data ) ) {
- thisObject = fn;
- fn = data;
- data = undefined;
- }
- fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject );
- return type === "unload" ? this.one(type, data, fn, thisObject) : this.each(function() {
- jQuery.event.add( this, type, fn, data );
- });
- },
-
- one: function( type, data, fn, thisObject ) {
+jQuery.each(["bind", "one"], function(i, name) {
+ jQuery.fn[ name ] = function( type, data, fn, thisObject ) {