Skip to content

Instantly share code, notes, and snippets.

@microbial
Created February 21, 2014 20:32
Show Gist options
  • Save microbial/9142857 to your computer and use it in GitHub Desktop.
Save microbial/9142857 to your computer and use it in GitHub Desktop.
onAvailable
//not mine
$.fn.onAvailable = function(fn) {
var sel = this.selector;
var timer;
var self = this;
if (this.length > 0) {
fn.call(this);
} else {
timer = setInterval(function() {
if ($(sel).length > 0) {
fn.call($(sel));
clearInterval(timer);
}
}, 50);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment