javascript - How to use datepicker in dynamically created jQuery UI dialog? -
i have trouble active datepicker() in dynamically created jquery ui dialog():
index.html
$(document).ready(function() { var $loading = $('<img src="./images/loading.gif" alt="loading">'); $('.page-popup').each(function() { var $dialog = $('<div></div>') .append($loading.clone()); var $link = $(this).one('click', function() { $dialog .load($link.attr('href')) .dialog({ title: $link.attr('title'), width: 600, height: 300 }); $link.click(function() { $dialog.dialog('open'); return false; }); return false; }); }); $( ".datepicker" ).datepicker({ dateformat: "yy-mm-dd" }); });
the external page gets loaded link that:
<a href="input.html" title="input" class="page-popup">input</a>
it has form select or correct date:
input.html
<form method="post" action="?"> <input type="text" name="date" value="2000-01-01" class="datepicker"> <input type="submit"> </form>
how can activate datepicker different dialogs?
render datepicker in open
event of dialog follows.
$dialog .load($link.attr('href')) .dialog({ title: $link.attr('title'), width: 600, height: 300, open: function(){ $( ".datepicker" ).datepicker({ dateformat: "yy-mm-dd" }); } });
Comments
Post a Comment