Created
July 30, 2010 14:59
-
-
Save cowboy/500667 to your computer and use it in GitHub Desktop.
jQuery liveOne: The power of .live and .one, together at last! (NOT FULLY TESTED) see http://jsfiddle.net/cowboy/gjcSE/
This file contains hidden or 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
/*! | |
* jQuery liveOne - v0.1 - 07/30/2010 | |
* http://benalman.com/ | |
* | |
* Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
*/ | |
// The power of .live and .one, together at last! | |
(function($,undefined){ | |
'$:nomunge'; // Used by YUI compressor. | |
$.fn.liveOne = function( types, data, fn ) { | |
var that = this; | |
if ( $.isFunction( data ) ) { | |
fn = data; | |
data = undefined; | |
} | |
function wrapper() { | |
that.die( types, wrapper ); | |
return fn.apply( this, arguments ); | |
}; | |
if ($.guid) { | |
wrapper.guid = fn.guid = fn.guid || $.guid++; | |
} | |
return that.live( types, data, wrapper ); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment