Is there a variant of jQuery's live() function that does not bind to events?
For example, I would like to do something like this:
$('.jdate').live(function() {
var datebox = $(this);
datebox.datepicker();
//do a couple more things
}
so all '.jdate' fields that are in the form and the ones that are added later through ajax are treated the same.
Checkout the jQuery livequery pluginwhat is this for that purpose.
Although the livequery plugin that @jAndy (or should I say @jAndy) mentioned will work, I'd consider it to be a last resort because of the overhead it requires.
If you're adding new elements to the DOM, you should simply call the plugin on those new elements when you add them.
$.ajax({
url:'/some/path/',
success:function(resp) {
var $resp = $( resp );
$resp.find('.jdate').datepicker();
$resp.appendTo('#myform');
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With