Skip to content

Instantly share code, notes, and snippets.

@pynej
Created May 29, 2015 14:19
Ensure Sample
$(document).ensure(function() {
return $("p.test").exists();
}).done(function() {
console.log("p.test exisits.");
});
$("body").ensure(function() {
return $("a", this).exists();
}).done(function(self) {
$("a", self).toggle();
});
$(selector).ensure({
delay: 500,
tries: 0,
isValid: function() {
return $(this).is(".loaded");
}
}).done(function(self) {
console.log("done loading resource");
}).fail(function() {
console.log("failed to load resource");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment