Friday, 6 September 2013

Datepicker for dynamically added elements with .on()

Datepicker for dynamically added elements with .on()

I'm loading HTML dynamically when a button is clicked. That html is then
shown in a modal window. It contains a <input type="text"
class="datepicker"/> element, for which I'd like to attach a datepicker. I
remember jQuery used to support .live() for this sort of stuff, but that's
been replaced by on(). However, I'm not sure how to correctly use on():
$('.datepicker').on('load', function() { $(this).datepicker(); });
does not work.

No comments:

Post a Comment