简体   繁体   中英

Dynatree jquery plugin add custom properties to node

I would like to add new properties to DynatreeNode class . For example in methods OnSelect I want to use node.myproperty. node.myproperty value is calculated from some DOM element. Is there a way to do this? I tried using jQuery extend, but it does'nt seem to be possible.

this is JavaScript, so you can create a new attribute virtually everywhere, simply by assigning it ;-)

For Dynatree, the recommended place would be the node.data object, eg

node.data.foo = "bar";

then access it:

onSelect(node){
    if(node.data.foo !== undefined){
        alert(node.data.foo);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM