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

Creating DatePickers from Jquery Objects not attached to the DOM

1 Answer 40 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Danny Fritz
Top achievements
Rank 1
Danny Fritz asked on 14 Oct 2014, 05:20 PM
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.

http://dojo.telerik.com/eqOsU

1 Answer, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 16 Oct 2014, 12:12 PM
Hi Danny ,

Basically, there are a couple of approaches that I could recommend:  
  • Append the input element, then initialize the widget: 
    $('<input/>').appendTo(document.body).kendoDatePicker();
  • 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.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Date/Time Pickers
Asked by
Danny Fritz
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or