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

Cleanup Best Practices

4 Answers 318 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Tess
Top achievements
Rank 1
Tess asked on 17 May 2012, 10:45 AM
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?

4 Answers, 1 is accepted

Sort by
0
Brian LeBaron
Top achievements
Rank 1
answered on 07 Mar 2013, 02:49 PM
I have this same question.
0
Atanas Korchev
Telerik team
answered on 12 Mar 2013, 02:33 PM
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!
0
Peter
Top achievements
Rank 1
answered on 21 Feb 2018, 05:22 AM

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?

0
Peter
Top achievements
Rank 1
answered on 21 Feb 2018, 06:27 AM
Apologies, ignore my issue, it was my fault. I was accidentally remove some of the DOM before allowing kendo to destroy it.
Tags
MVVM
Asked by
Tess
Top achievements
Rank 1
Answers by
Brian LeBaron
Top achievements
Rank 1
Atanas Korchev
Telerik team
Peter
Top achievements
Rank 1
Share this question
or