This question is locked. New answers and comments are not allowed.
I have a treeview that I'm dynamically loading the child nodes for using Ajax (the parent level is via a server side model pased to the view). This works fine. I've registered an event on the OnSelect using the ClientSide event registration in the view, this also fires fine. In this event handler I'm trying to load a div dynamically using the value of the item selected, this I can't figure out. I've checked the demo's and the documentation for the API but I can't get a consistent answer. All the example seem to use what looks like a data key of tTreeView. Where did this come from? I tried to replicate the demo's but I couldn't. So I started trial and error using Chrome's javascript console when the onSelect event was fired to try and hack my way through it. I have what "technically" works but I don't see why.
My event registration looks like this
$(this).data(this);
I don't even have to do it for every call, I just called it once on the page and then the page works fine with my existing code until I reload the page, even child nodes that are populated after the call is made. I tried combining the two but It doesn't work. I found that it's not the return value of the .data(this) function that works it's the effect it has on calling .data() afterwards that it alters.
Doesn't work
Doesn't Work
Doesn't work
Works
How are the examples on the documentation and demo sites supposed to work? Cause while I found that my code above does the trick I have a funny feeling it won't work so well for multiple treeviews on one page.
Oh and I'm using 2011.2.712.340
My event registration looks like this
This gives an error when I select a node. I've tried passing a value into the data() function but nothing seems to get me anywhere closer to finding a definition of getItemValue. However, when I click on a node, if I break into the javascript console and run this first my code works..ClientEvents(e =>e.OnSelect(
@<text>function(e) { alert($(
this
).data().getItemValue(e.item));}
</text>))
$(this).data(this);
I don't even have to do it for every call, I just called it once on the page and then the page works fine with my existing code until I reload the page, even child nodes that are populated after the call is made. I tried combining the two but It doesn't work. I found that it's not the return value of the .data(this) function that works it's the effect it has on calling .data() afterwards that it alters.
Doesn't work
alert($(
this
).data().getItemValue(e.Item));
Doesn't Work
alert($(
this
).data(
this
).getItemValue(e.Item));
Doesn't work
var
test = $(
this
).data(
this
)
alert(test.getItemValue(e.Item));
Works
$(
this
).data(
this
);
alert($(
this
).data().getItemValue(e.Item));
How are the examples on the documentation and demo sites supposed to work? Cause while I found that my code above does the trick I have a funny feeling it won't work so well for multiple treeviews on one page.
Oh and I'm using 2011.2.712.340