Unplanned
Last Updated: 06 Jun 2019 12:09 by Eva
Eduard Töws
Created on: 08 Feb 2019 07:48
Category: Kendo UI for jQuery
Type: Feature Request
2
Widgets in Dialog are not destroyed at Dialog.destroy()
Hello ladies and gentlemen.

At call of Dialog.destroy() will not destroy the widgets inited in Dialog.element

Window destroy:
...
_destroy: function () {
    if (this.resizing) {
            this.resizing.destroy();
    }
    if (this.dragging) {
            this.dragging.destroy();
    }
    this.wrapper.off(NS).children(KWINDOWCONTENT).off(NS).end().find('.k-resize-handle,.k-window-titlebar').off(NS);
    $(window).off('resize' + NS + this._marker);
    $(window).off(MODAL_NS);
    $(window).off(NS);
    clearTimeout(this._loadingIconTimeout);
    Widget.fn.destroy.call(this);
    this.unbind(undefined);
    kendo.destroy(this.wrapper);
    this._removeOverlay(true);
},
destroy: function () {
    this._destroy();
    this.wrapper.empty().remove();
    this.wrapper = this.appendTo = this.element = $();
},
...

Dialog destroy:
...
destroy: function () {
    var that = this;
    that._destroy();
    Widget.fn.destroy.call(that);
    that.wrapper.remove();
    that.wrapper = that.element = $();
},
_destroy: function () {
    var that = this;
    var ns = '.' + NS;
    that.wrapper.off(ns);
    that.element.off(ns);
    that.wrapper.find(KICONCLOSE + ',' + KBUTTONGROUP + ' > ' + KBUTTON).off(ns);
    that._stopCenterOnResize();
},
...

In Dialog.detroy() will kendo.destroy() not be called.

Best regards,
Eduard Töws

3 comments
Eva
Posted on: 06 Jun 2019 12:09

Hey Eduard,

 

firstly thank you very much for your answer. It was very helpful. It seems to work but we have to test more..

 

My code snippet is:

let kendoDialog = dialog.kendoDialog({

            hide: function() {

                kendo.destroy(this.element.wrapInner("<div></div>").children());
                this.destroy();


            }
        }).data("kendoDialog");

 

Kind regards,

Eva

             
Eduard Töws
Posted on: 05 Jun 2019 20:19

Hi Eva.

The last answer to my internal ticket was in February 2019.

On my suggestion of fixing:

...
destroy: function () {
  var that = this;
  that._destroy();
  Widget.fn.destroy.call(that);
  kendo.destroy(that.wrapper);//fix. destroy children
  that.wrapper.remove();
  that.wrapper = that.element = $();
},
...

was answered:

"... Destroying multiple widgets within it could have a negative impact on its closing speed ... Thus I created a Feature Request item in our Feedback Portal on your behalf. You can vote for it and based on the support if receives from the community it could get approved for implementation by the team..."

##############

This can be temporar fixed as follows:

var originalKendoUiDialogDestroy = kendo.ui.Dialog.prototype.destroy;
kendo.ui.Dialog.prototype.destroy = function() {
  kendo.destroy(this.element.wrapInner("<div></div>").children());
  originalKendoUiDialogDestroy.call(this);
};

Regards,
Eduard Töws

Eva
Posted on: 05 Jun 2019 14:46
Any answers about it? I have the same problem.