Cleanup Best Practices

5 posts, 0 answers
  1. Tess
    Tess avatar
    6 posts
    Member since:
    Apr 2012

    Posted 17 May 2012 Link to this post

    My application has a lot of windows, containing forms and other views of data that have been bound to observables, using the kendo.bind function.  Many of these windows are created and destroyed, over the course of the application lifetime.

    My question is this:  Is it necessary to call kendo.unbind on the contents of these windows, prior to destroying them, or will they automatically clean up their observable bindings?

    Also, are there any other best practices I should be aware of, for tidying up after deleting these form windows?
  2. Brian LeBaron
    Brian LeBaron avatar
    2 posts
    Member since:
    May 2010

    Posted 07 Mar 2013 Link to this post

    I have this same question.
  3. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 12 Mar 2013 Link to this post

    Hello,

     The recommended cleanup method is to call the destroy() method of the Kendo UI widgets. A convenient method called kendo.destroy can be used to find all Kendo UI widgets in a DOM tree.

     Here is an example:
     
    <div id="widget-container">
          <input id="autocomplete" />
          <input id="numerictextbox" />
    </div>
    <script>
          $("#autocomplete").kendoAutoComplete();
          $("#numerictextbox").kendoNumericTextBox();  
    </script>

    <script>
     //cleanup all widgets inside "widget-container"

     kendo.destroy($("#widget-container"));
    </script>

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  4. Peter
    Peter avatar
    55 posts
    Member since:
    Jan 2014

    Posted 20 Feb in reply to Atanas Korchev Link to this post

    Hi This is very useful.

    But I'm having problems cleaning up kendo components, because for some reason, kendo generates DOM and appends it to BODY - even though what I'm doing, is completely and utterly contained within #my-div

    So these elements are never destroyed. I guess because they are not contained within the $("#my-div") - and my DOM grows endlessly with kendo widget elements because of this

    Is there any way to stop kendo generating DOM elements outside the container I've restricted the binding to?

  5. Peter
    Peter avatar
    55 posts
    Member since:
    Jan 2014

    Posted 21 Feb in reply to Peter Link to this post

    Apologies, ignore my issue, it was my fault. I was accidentally remove some of the DOM before allowing kendo to destroy it.
Back to Top