DatePicker span elements hanging around after destroy

4 posts, 0 answers
  1. Ryan
    Ryan avatar
    11 posts
    Member since:
    Jan 2016

    Posted 14 May Link to this post

    I'm not sure if this is expected behavior, but when you destroy a KendoDatePicker, the spans that Kendo creates on initialization of the widget stick around afterwards.  It seems like something that Kendo should be cleaning up when it destroys a widget, since they are Kendo specific elements it added to the DOM.

    Dojo to reproduce:
    https://dojo.telerik.com/OBImobad
  2. Stefan
    Admin
    Stefan avatar
    1938 posts

    Posted 15 May Link to this post

    Hello, Ryan,

    Thank you for the example.

    The spans are still on the page as the widget that has wrapper elements as the DatePicker, instead of removing the initial DOM element used to create the widget, the wrapper has to be removed:

    https://dojo.telerik.com/OBImobad/2

    As the wrappers have a more generic class selector, if there are more elements,  and only one has to be removed, the selector has to be made more specific.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Ryan
    Ryan avatar
    11 posts
    Member since:
    Jan 2016

    Posted 15 May in reply to Stefan Link to this post

    Hi Stefan,
    That's where my question stemmed from though, shouldn't all those extra elements attached to the DOM by Kendo be removed from the DOM by Kendo as well, on destroy?

    To me, it seems like that is a Kendo responsibility and not the end-user
  4. Stefan
    Admin
    Stefan avatar
    1938 posts

    Posted 16 May Link to this post

    Hello, Ryan,

    Thank you for the feedback.

    In general, the destroy method has a function to destroy the bindings and the different attached event listeners. This is the reason is our destroy article we advised the removing of the DOM elements has to be done programmatically by the developer:

    https://docs.telerik.com/kendo-ui/intro/widget-basics/destroy#destroying-widgets

    We do not remove the DOM automatically, as in some cases the developer may want to reuse the same DOM element. Removing it and then adding it again could create unnecessary DOM operations which can slow the application.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top