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

How to properly remove MobileView from DOM

3 Answers 87 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Marlon
Top achievements
Rank 1
Marlon asked on 03 Jan 2014, 10:20 PM
I'm working on an app with some particularly heavy views that I'd like to remove from the DOM if iOS reports a memory warning. What is the preferred method for this? For testing I tried adding:
hide:function(e) {
  e.view.destroy();
  e.view.element.remove();
},
where 'hide' is my view's callback for when the view is hidden. It's removed from the DOM but when I try to load it again, I get a js error from the kendo.js file:

Line 9: TypeError: 'undefined' is not an object (evaluating 'this.element.closest');

Am I missing something?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 06 Jan 2014, 11:37 AM
Hi Marlon,

Once the View is removed from the DOM, you can no longer navigate to it, so the error message that you see there is expected as the element is no longer available and won't be recreated automatically by the mobile application. If this is not the case, please elaborate a bit more and add a runnable sample that we can take a look at. 

Thank you in advance for your cooperation.

Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Marlon
Top achievements
Rank 1
answered on 06 Jan 2014, 03:04 PM
OK thank you I understand now. Is there an efficient way to safely remove a view from the DOM AND the mobile application, then recreate it when its requested again? Or is the refresh=true config parameter the closest that I can get to that?

And if refresh is my only recourse...Does it automatically flush the DOM on hide or does the view stay as-is until its shown again? My main focus it so lighten the DOM footprint as much as possible if there is a memory warning so I want to be able to destroy as much as I can and recreate when its requested again.
0
Kiril Nikolov
Telerik team
answered on 07 Jan 2014, 11:50 AM
Hi Marlon,

Once the application is initialized adding views dynamically is not supported. You can use the hide event to delete the view and then using data-reload="true" it will load the view again.

I am not familiar with your project, but do you really need this memory optimization or is it just a precautionary measure? Because so far I have not had a case where memory problems were reported.

Regards,
Kiril Nikolov
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
Marlon
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Marlon
Top achievements
Rank 1
Share this question
or