Reputation: 693
How do I attach a JQuery Mobile DatePicker dynamically to an input field ?
I tried using ui-datepicker, but I think the plugin attaches Calendar to the input field that has the required markup. How do I dynamically attach a calendar using Javascript ? I tried the following
$("#datep").after( $( "<div />" ).datepicker({
altField: "#datep"
}) );
but the Calendar does not hide after the date has been chosen.
I also explored jQM-DateBox2, but couldn't figure out a way to attach calendar dynamically.
Any help would be appreciated.
Upvotes: 0
Views: 412
Reputation: 1984
To do this with DateBox, you could do something like:
$('<input data-role="datebox" ...etc.. >').appendTo(whatever).trigger('create');
OR, you could add the input field wherever you like, and then
$('#added_element').datebox({<optional options});
Upvotes: 1