How to properly remove MobileView from DOM

4 posts, 0 answers
  1. Marlon
    Marlon avatar
    16 posts
    Member since:
    Jul 2013

    Posted 03 Jan 2014 Link to this post

    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!
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 06 Jan 2014 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Marlon
    Marlon avatar
    16 posts
    Member since:
    Jul 2013

    Posted 06 Jan 2014 Link to this post

    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.
  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 07 Jan 2014 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready