Datepicker not working second time when loading dialog with ajax

2 posts, 1 answers
  1. Sergi
    Sergi avatar
    34 posts
    Member since:
    Sep 2007

    Posted 12 Aug 2013 Link to this post

    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.
  2. Answer
    Sergi
    Sergi avatar
    34 posts
    Member since:
    Sep 2007

    Posted 12 Aug 2013 Link to this post

    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"); }
  3. Kendo UI is VS 2017 Ready
Back to Top