Closed GoogleCodeExporter closed 9 years ago
Does
var node = $.ui.dynatree.getNode(el);
...
work?
Original comment by moo...@wwwendt.de
on 15 Nov 2011 at 7:12
console.log(el):
<span class="dynatree-node dynatree-expanded dynatree-has-children
dynatree-exp-e dynatree-ico-e">
<span class="dynatree-expander"></span>
<span style="display: inline-block" id="ic_1__100194"></span>
<a href="#" class="dynatree-title">Sample</a>
</span>
]
var node = $.ui.dynatree.getNode(el);
console.log(node):
undefined
It seems not be able to get the node.
Original comment by mrdu...@gmail.com
on 15 Nov 2011 at 7:27
I (hopefully) fixed this with issue 247, can you confirm?
Original comment by moo...@wwwendt.de
on 15 Nov 2011 at 8:34
Thanks a lot, that fixed it!
var node = el.parents('[dtnode]').prop('dtnode'); doesn't work,
but this works now: (r533)
var node = $.ui.dynatree.getNode(el);
Original comment by mrdu...@gmail.com
on 15 Nov 2011 at 9:41
Testing with DynaTree 1.2.0 release on Windows Server 2003:
Firefox 8: getNode does not work
Chrome 16: getNode does not work
IE8: getNode works
This works in FF8, Chrome 16, and IE 8:
var $el = el.jquery === undefined ? $(el) : el;
var node;
$.each( $el.parents(), function( index, parent ) {
node = parent.dtnode;
if( node ) {
return false;
}
});
return node;
Original comment by mang...@zapsiteexpress.com
on 21 Dec 2011 at 5:54
The latest release uses plain JS (not jQuery).
Hope this works on all browsers:
$.ui.dynatree.getNode = function(el) {
if(el instanceof DynaTreeNode){
return el; // el already was a DynaTreeNode
}
while( el ) {
if(el.dtnode) {
return el.dtnode;
}
el = el.parentNode;
}
return null;
}
Original comment by moo...@wwwendt.de
on 27 Dec 2011 at 8:01
Original issue reported on code.google.com by
mrdu...@gmail.com
on 15 Nov 2011 at 6:40