Destruction

class webix.Destruction()

Destruction mixin

References

helpers
views().

Referenced by

components
DataCollection().
views
baseview().

External references

Official documentation page.

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
webix.Destruction = {
    $init:function(){
        //wrap in object to simplify removing self-reference
        var t  = this._destructor_handler = { obj: this};

        //register self in global list of destructors
        webix.destructors.push(t);
    },
    //will be called automatically on unload, can be called manually
    //simplifies job of GC
    destructor:function(){
        var config = this._settings;

        if (this._last_editor)
            this.editCancel();

        if(this.callEvent)
            this.callEvent("onDestruct",[]);

        //destructor can be called only once
        this.destructor=function(){};
        //remove self reference from global destructions collection
        this._destructor_handler.obj = null;

        //destroy child and related cells
        if (this.getChildViews){
            var cells = this.getChildViews();
            if (cells)
                for (var i=0; i < cells.length; i++)
                    cells[i].destructor();

            if (this._destroy_with_me)
                for (var i=0; i < this._destroy_with_me.length; i++)
                    this._destroy_with_me[i].destructor();
        }

        delete webix.ui.views[config.id];

        if (config.$id){
            var top = this.getTopParentView();
            if (top && top._destroy_child)
                top._destroy_child(config.$id);
        }

        //html collection
        this._htmlmap  = null;
        this._htmlrows = null;
        this._html = null;


        if (this._contentobj) {
            this._contentobj.innerHTML="";
            this._contentobj._htmlmap = null;
        }

        //removes view container
        if (this._viewobj&&this._viewobj.parentNode){
            this._viewobj.parentNode.removeChild(this._viewobj);
        }

        if (this.data && this.data.destructor)
            this.data.destructor();

        if (this.unbind)
            this.unbind();

        this.data = null;
        this._viewobj = this.$view = this._contentobj = this._dataobj = null;
        this._evs_events = this._evs_handlers = {};

        //remove focus from destructed view
        if (webix.UIManager._view == this)
            webix.UIManager._view = null;

        var url = config.url;
        if (url && url.$proxy && url.release)
            url.release();

        this.$scope = null;
        // this flag is checked in delay method
        this.$destructed = true;
    }
};
//global list of destructors