Skip to forum content

Mif

— mystic javascript interface

You are not logged in. Please login or register.


Post new reply

Post new reply

Compose and post your new reply

You may use: BBCode Images Smilies

All fields labelled (Required) must be completed before the form is submitted.

Required information for guests



Captcha image. Turn pictures on to see it.
Required information
Optional post settings

Topic review (newest first)

1

Blah.  Here's an easier solution:

var node = tree.getSelected();
var new_node =  new Mif.Tree.Node({
    parentNode  : node,
    tree        : tree
    }, {property: {name: foobar.getTmpName(node),}
});
tree.add(new_node, node, 'inside');
new_node.rename();

lol

2

LOLz... I noticed that I kept on replying to my own threads.  Anyway, I just overrode the add() method:

Mif.Tree.implement({
    add: function(node, current, where){
        if(!(node instanceof Mif.Tree.Node)){
            node=new Mif.Tree.Node({
                parentNode: null,
                tree: this
            }, node);
        };
        node.inject(current, where, Mif.Tree.Draw.node(node));
        this.fireEvent('add', [node, current, where]);
        node.rename();

        return this;
    }
});

I hope this solutions helps other people too! smile

3

Hi,

Is there a way to select a newly added node?  I need a way to do this because I wish to automatically call rename() after adding each node.

After reading this thread http://mifjs.net/forum/topic/77/, I figured that perhaps I can do something like tree.select(tree.ids[uid]), but my browser tells me that "tree.ids" has no properties.

Regards,

[ simon.cpu ]