Refresh ModalView

3 posts, 1 answers
  1. Bill
    Bill avatar
    75 posts
    Member since:
    Feb 2013

    Posted 03 Jul 2013 Link to this post

    I have a view which is a remote view.  As a result, the content of the view is dynamic.  I have a button on this dynamic view which opens a modal view to show some details.  The details are dynamic and directly related to its parent remote view to which the modal view was opened from.

    It appears ModalViews are cached like Views.  So my dynamic content I am putting in them are never displayed as it pulls the modal view from cache after the initial load.  How can I destroy/remove a ModalView?

    I've been successful in removing Views from the cache before (see below) but I don't know how to retrieve/remove ModalViews in a similar manner.
    function dataHide(e) {
        var div = $('#' + e.view.content.context.id);
        if (div) div.remove();
        e.view.destroy();
    }
  2. Answer
    Bill
    Bill avatar
    75 posts
    Member since:
    Feb 2013

    Posted 03 Jul 2013 Link to this post

    I found a way to remove all modal views as well as remove the view itself on the view hide event...  here's the code:
    //remove modal views
    $("div[data-role='modalview']").each(function () {
        var modalView = $(this).data("kendoMobileModalView");
        if (modalView) modalView.destroy();
     
        var $modalContainer = null;
     
        $(this).parents().each(function () {
            if ($(this).parent().prop("tagName") == "BODY") {
                $modalContainer = $(this);
                return false;
            }
        });
     
        if ($modalContainer != null && $modalContainer.length > 0) $modalContainer.remove();
    });
     
    //remove view
    var $viewDiv = $('#' + e.view.content.context.id);
    if ($viewDiv.length > 0) $viewDiv.remove();
    if (e.view) e.view.destroy();
  3. Kendo UI is VS 2017 Ready
  4. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 05 Jul 2013 Link to this post

    Hello Bill,

    Thank you for contacting us regarding this problem. While relatively rare, I think that the current modalview destroy behavior is incorrect. We will make sure that calling the destroy method removes the respective widget elements and wrappers in our next release. 

    I am updating your telerik points for this finding. 

    Regards,
    Petyo
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top