Not a problem, thanks for replying though.
I figured out where I was going wrong.
The order in which I was injecting the nodes was incorrect. Also I had
accidentally used the 'options' node object instead of 'this'
So with the following changes it is working fine.
In MooTreeNode: initialize(options) added
if(this.position != undefined && this.position != null){
var prevNode = this.parent.nodes[this.position-1];
var prevNodeDiv = prevNode.div;
//Insert the current main div after previous sub div
$(this.div.main).inject(prevNodeDiv.sub, 'after');
//Insert the current sub div after the current main div
$(this.div.sub).inject(this.div.main, 'after');
}
Thanks,