MVC treeview click event
I am really new to the MVC/jQuery world and having trouble getting the
full picture how to set up and handle a treeview click event to pass the
full path (Parent & Children) values to a MVC Controller in the treeview
below. Example: If I click on Houston. I would like to get the parent path
USA,Texas,Houston and then pass to a Controller. If just Texas, then I
want USA,Texas. I am using the jstree.com tree view. Thank you for the
help.
P.S. In the console log it's say: Uncaught TypeError: Cannot read property
'value' of undefined
<div id="divtree">
<ul id="tree" >
<li>
<a href="#">Locations</a>
<ul>
<li onclick="selectNode(event, this);" >
<a href="#">Texas</a>
<ul>
<li onclick="selectNode(event, this);" >
<a href="#">Houston</a>
<ul>
<li onclick="selectNode(event,
this);" >
<a href="#">Katy</a>
</li>
</ul>
<ul>
<li onclick="selectNode(event,
this);" >
<a href="#">Spring</a>
</li>
</ul>
<script type="text/javascript">
function selectNode(event,
nodeHtmlEl) {
console.log("selectNode Info:
" +
$(nodeHtmlEl).attr("li").value);
}
</script>
</li>
</ul>
<script type="text/javascript">
function selectNode(event, nodeHtmlEl) {
console.log("selectNode Info: " +
$(nodeHtmlEl).attr("li").value);
}
</script>
</li>
</ul>
<script type="text/javascript">
function selectNode(event, nodeHtmlEl) {
console.log("selectNode Info: " +
$(nodeHtmlEl).attr("li").value);
}
</script>
</li>
</ul>
</div>
No comments:
Post a Comment