[jQuery] $('#foo').ready(function() { ... });
In my current project Im finding my self to a lot of
$(document).ready(function() {
if($('#foo').size == 1) {
.......
}
});
Now im thinking of a way to extend jquery something like this:
$.fn.cready = function(callback) {
if($(this).size() == 1) {
try {
c = this;
$(document).ready(function() {
(callback || function(){}).apply(c);
});
} catch(e) {}
}
return this;
}
but when i run $('#foo').cready(function() { ... }); the dom is
obiviously not ready so $(this).size() == 0
Any suggestions on how i can solve this in a clean way?