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

Refresh ModalView

2 Answers 127 Views
ModalView
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 03 Jul 2013, 03:03 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Bill
Top achievements
Rank 1
answered on 03 Jul 2013, 09:33 PM
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();
0
Petyo
Telerik team
answered on 05 Jul 2013, 11:15 AM
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!
Tags
ModalView
Asked by
Bill
Top achievements
Rank 1
Answers by
Bill
Top achievements
Rank 1
Petyo
Telerik team
Share this question
or