javascript - adding a property to an object in js -


i have jstree populated code:

jquery(function($) {         var treeslist = {!trees};         for(j=0; j<treeslist.length; j++) {             console.log(treeslist[j]);             $("#jstree"+treeslist[j].attr.promotion_item).jstree({ // here define tree structure                 "core" : { "animation" : 200 },                 "json_data" : { "data" : treeslist[j]},                  "themes" : {"dots" : false, "theme" : "classic"},                 "types" : { "types" : {                     "default" : { "icon" : { "image" : null } },                 } },                 "plugins" : [ "themes", "json_data" , "types"]             });           }         rerendertable();      }); 

i want set href attribute json_data if print treeslist element, data has title not href attribute.

how can add js in order jstree view , populate in generated li element? i've tried with:

treeslist[j].data.attr = ""; treeslist[j].data.attr.href = "link"; 

but undefined value.

this have:

object { title="iphone3s"} 

what got:

object { title="iphone3s", attr=""} 

what think need makethe jstree link work

object { title="iphone3s", attr= {href="link"}} 

thanks.

try this,

treeslist[j].data.attr= {href:"link"}; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -