HI all,

I am new to Jquery so am struggling with certain aspects. I want to
populate a text box with the node that
I click on so that I as I traverse the tree down I would get a built
up string of the file path ....

eg.
first click:        HR Management/
second click:   HR Management/Attendance Management.zip


I setup the treeview using JSON string as follows:

[
    {
        "text": "HR Management",
        "classes": "important",
        "children": [
            {
                "text": "Attendance Management.zip"
            }
        ]
    },
    {
        "text": "Regulatory Compliance",
        "classes": "important",
        "children": [
            {
                "text": "ADA-What Supervisors Need to Know.zip"
            }
        ]
    }
]

The problem with this is that depending where I click I can end up
getting more information in the text box than
I need ....all the text is getting selected..
eg.
 HR ManagementAttendance Management.zipRegulatory ComplianceADA-What
Supervisors Need to Know.zip


<script type="text/javascript">
              $(document).ready(function() {
                $(document).bind("click", function(e) {
                $(e.target).find("ul").find("li").toggleClass("last").find
("span");
                var $kids = $(e.target).children();
                var len = $kids.addClass("last").text();
                        // populate a textbox with what was clicked on
                document.getElementById("nodePicked").value = len;
                e.preventDefault();
                return false;
                });
            });
</script>

---------------------------------------------------------------------
Here is the dynamic Markup that gets generated:
---------------------------------------------------------------------
<div id="" class="viewStyle" style="border-style: none solid; border-
left: 1px solid DarkBlue; border-right: 1px solid DarkBlue; width:
100%;">
   <ul id="black" class="treeview">
      <li id="" class="collapsable">
       <div class="hitarea collapsable-hitarea"/>
          <span class="important">HR Management</span>
             <ul style="display: block;">
               <li id="" class="last">
                 <span class="last">Attendance Management.zip</span>
               </li>
             </ul>
       </li>
      <li id="" class="expandable">
        <div class="hitarea expandable-hitarea"/>
          <span class="important">Regulatory Compliance</span>
             <ul style="display: none;">
                <li id="" class="last">
                <span>ADA-What Supervisors Need to Know.zip</span>
                 </li>
            </ul>
      </li>
     <li id="" class="expandable lastExpandable">   ( more node info
not displayed for brevity sake)
   </li>
 </ul>
</div>

Thanks in advance for anyones help with this matter....

Craig T.

Reply via email to