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

Ajax and replacing Kendo Controls

3 Answers 57 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Anthony asked on 15 Jul 2014, 11:13 AM
Hi
  Just for confirmation, it seems to work ok

Assume we have something like this:

<div id=theContents>
  <input type=button id=theButton>

    <script>
      $('#theButton').kendoButton()
    </script>
</div>

If this div is replaced with another copy via ajax (i.e. it's in an MVC partial file) is this safe as far as kendo is concerned?

i.e. when the kendoButton function is called it obviously changes the html around the button but are those changes limited to inside the div, are there stray bits of html floating around outside of the div, possibly at the body level, which could cause problems later?

thanks

3 Answers, 1 is accepted

Sort by
0
Kamen Bundev
Telerik team
answered on 15 Jul 2014, 02:58 PM
Hello Anthony,

The Button widget itself doesn't have additional HTML outside of its element. However, there might be some events attached to external elements, so make sure to call kendo.destroy("#theContents") before replacing it - it will make sure to detach any events and destroy the JavaScript objects of the widgets inside that container, thus also preventing memory leaks.

Let me know if this helps.

Regards,
Kamen Bundev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Anthony
Top achievements
Rank 1
answered on 15 Jul 2014, 07:01 PM
Thanks for the reply

I mean that more as a general question and approach, so it is also ok for the datepicker, grid and any other controls? Assuming I called destroy first
0
Kamen Bundev
Telerik team
answered on 16 Jul 2014, 07:02 AM
Hello Anthony,

Yes. Actually all widgets have their own destroy method, so if you have only one widget - you can use that instead, as it also calls kendo.destroy on its contents. However, kendo.destroy() is very useful for containers, that contain many widgets and you don't want to hunt them all down in order to destroy them one by one.

Regards,
Kamen Bundev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
General Discussions
Asked by
Anthony
Top achievements
Rank 1
Answers by
Kamen Bundev
Telerik team
Anthony
Top achievements
Rank 1
Share this question
or