Tree view

Tree view

i an creating div dynamically and change id for div and bind tree with new tee but tree is not working.
int dynamicalyID=1;
$('.treegroup').append(''<div id=newID></div>);
$('#newID').attr('id,newID+ dynamicalyID);

('#newID'+ dynamicalyID).tree({
primarykey:'id',
datasource:record,
)};

dynamicalyID++

note: if i use  blow code then working but approch one for dynamically tree.
('#newID').tree({
primarykey:'id',
datasource:record,
)};