Hi, everyone!
I have two fields with datepicker inside a dialog. When I use them inside this dialog, everything works fine. The problem is when I close my dialog and re-open it to do other requests. My datepicker re-initialize whitout selecting any fields and do not close again.
I've tried to close it manually with the dialog's close property but when I re-open it, my datepicker does'nt open again.
Any idea?
- My form
- <div>
- <form onsubmit="return false;" id="formDialog">
- <input type="hidden" name="id" value="${id}"/>
- <input type="hidden" name="domain" value="${domain}"/>
- <label for="all">Period</label> <br>
- <input type="text" class="datePicker" name="startDate"/> to
- <input type="text" class="datePicker" name="endDate"/>
- <input type="submit" value="Search" class="btn"/>
- </form>
- <div id="formDataPanel">
- </div>
- </div>
- <asset:javascript src="jqueryui/jquery-ui.js"/>
- <script type="text/javascript">
- $(".datePicker").datepicker({
- dateFormat:"dd/mm/yy",
- onClose: function () {
- $(this).datepicker('refresh');
- }
- });
- $("#formDialog").submit(function() {
- // $(".datePicker").datepicker("destroy")
- $.ajax(
- $("#appContext").val() + "myEndpoint",
- {
- data:$("#formDialog").serialize(),
- success: function(data, textStatus, jqXHR) {
- $("#formDataPanel").html(data)
- }
- }
- )
- return false;
- })
- </script>
- My other js file
- //= require jqueryui/jquery-ui.js
- //= require_self
- function functionToRequest(domain, id) {
- $("#selector")
- .load($("#appContext").val() + "auditoria/domain?id=" + id + "&domain=" + domain)
- .dialog({
- modal:true,
- closeOnEscape:true,
- title:'MyTitle',
- width:'70vw',
- height:300
- });
- }
- jQuery(document).ready(function() {
- $("body").append("<div id=\"selector\"></div>")
- })