3

This is the data format for my nodes:

{
data: "new Structure",
attr: {id:"1", class:"structureNode", rel:"root"}
}

I have a reference for the node in question, and I can easily get the attributes

nodeReference.attr('attributeName')

However, I can't get access to the node name, stored in "data". Is there any way to get access to this while having a node reference (other than searching through the DOM to find the text in the <a> field, which I find very cumbersome)?

I've considered storing the name in the attr array as well, but I don't like to have redundancy.

Thanks :-)

Reporter
  • 3,897
  • 5
  • 33
  • 47
nicohvi
  • 2,270
  • 2
  • 28
  • 42
  • Do you mean the link description between and ? – Reporter Jul 01 '11 at 08:58
  • Yeah, the node name is between and in the document, but I feel like there should be a way to access the data of the node when I have a reference for it. – nicohvi Jul 01 '11 at 09:11
  • Have you already tried the method '.data' from standard dom (or standard javascript)? It looks like "nodeReference.data". – Reporter Jul 01 '11 at 10:27
  • Yeah, tried that. That just returns the jQuery data function: function (key, value) { var data = null; if (typeof key === "undefined") { if (this.length) { data = jQuery.data(this[0]); ... etc – nicohvi Jul 01 '11 at 10:46
  • without any example is hardly possible to make any soloution – Reporter Jul 01 '11 at 11:00
  • I don't understand what other information you would need? I can access all the attributes using the example I provided, but I don't have a way to access the "data" field. nodeReference.data didn't work, as that just gave me the functions available with jQuery .data(). My question is just basically: Is there a way to access a jstree node's "data" field, in the same was as its "attr" field? – nicohvi Jul 01 '11 at 11:05

1 Answers1

4

I found the solution in the documentation. Apparently, all you need is .get_text(nodeReference) :-)

nicohvi
  • 2,270
  • 2
  • 28
  • 42