This is a migrated thread and some comments may be shown as answers.

Datepicker not working second time when loading dialog with ajax

1 Answer 309 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Sergi
Top achievements
Rank 1
Sergi asked on 12 Aug 2013, 07:37 AM
Hello.

I have a dialog that is loaded from ajax and shown with jquery ui dialog, the html returned by ajax contains a kendo ui datepicker, this datepicker works the first time, but after closing the dialog and opening it again the datepicker is just a text input with no kendo behaviour.

I'm using the MVC helpers, the HTML returned by ajax is like this:
<form action="@Url.Action("Save", "Calendario")" method="post" data-as-ajax="edit-appointment">
       <input type="hidden" name="ID" value="@Model.ID" />
       <div class="row">
           <label for="FechaInicio">Fecha Inicio</label>
           @Html.Kendo().DatePicker().Name("FechaInicio").Value(Model.FechaInicio)
       </div>
       <div class="row">
           <label for="Asunto">Asunto</label>
           <textarea name="Asunto">@Model.Asunto</textarea>
       </div>
       <div class="row">
           <label for="Observaciones">Observaciones</label>
           <textarea name="Observaciones">@Model.Observaciones</textarea>
       </div>
       <input type="submit" value="Guardar" />
   </form>

How can I fix it so that it always works, and not only the first time?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Sergi
Top achievements
Rank 1
answered on 12 Aug 2013, 07:42 AM
Nevermind, for some reason the dialog wasn't getting destroyed on close, I just added this to the dialog options and now it works every time:

close: function (event, ui) { $(this).dialog("destroy"); }
Tags
Date/Time Pickers
Asked by
Sergi
Top achievements
Rank 1
Answers by
Sergi
Top achievements
Rank 1
Share this question
or