Topic: delete tree

Hi Moro,

How do you delete the content of a tree? (or subtree)

I have a Mif.Tree object which I populated using load(json...). But I would like to clear it to re-populate it with new data. If I call load twice, the new data is appended to the previous one.

Cheers,
Peter

Re: delete tree

Mif.Tree.implement({
    
    del: function(){
        this.UID=0;
        this.$={};
        this.$index=null;
        this.mouse.node=false;
        this.unselect();
        this.wrapper.innerHTML='';
    }
    
});

Re: delete tree

Thank you moro, that works great smile

PS: Sorry for the late feedback...

Re: delete tree

I have modified your code because of an error :
Uncaught TypeError: Cannot call method 'indexOf' of null : line 1 (surely on this.$index == null)

Mif.Tree.implement({
    del: function()
    {
        this.UID = 0;
        this.$ = {};
        this.$index = []; // Array, not null
        this.mouse.node = false;
        this.unselect();
        this.wrapper.innerHTML = '';
    }
});

Thanks for the help!