Creating DatePickers from Jquery Objects not attached to the DOM

2 posts, 1 answers
  1. Danny Fritz
    Danny Fritz avatar
    18 posts
    Member since:
    Jul 2012

    Posted 14 Oct 2014 Link to this post

    If I'm turning an `<input>` into a kendoDateTimePicker before it is attached to the DOM, how do I then attach the newly wrapped element to the DOM? Just appending the `<input>` element appends an incomplete portion of the control because the `<input>` was wrapped. Was wondering if there was a better way then traversing for the parent `k-widget` class to append.
  2. Answer
    Alexander Popov
    Alexander Popov avatar
    1436 posts

    Posted 16 Oct 2014 Link to this post

    Hi Danny ,

    Basically, there are a couple of approaches that I could recommend:  
    • Append the input element, then initialize the widget: 
    • Get the instance of the widget and use its wrapper property as parameter for the append method: 
      var datetimepicker = $('<input/>').kendoDateTimePicker().getKendoDateTimePicker();
      $(document.body).append(datetimepicker .wrapper);

    I would suggest using the first approach, as moving existing widgets inside the DOM could have undesired results.

    Alexander Popov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top