I have the need to pass an object from jstl to a Jquery click handler.
My UI displays a tree structure. The nodes which make up the tree use a name property which is the value displayed to the user. This name property is taken from a “node” object. Is there any way i can pass the “node” object into my jquery function when one of the nodes of the tree is clicked?
My jstl looks like this
<c:forEach var="node" items="${object.childItems}">
<li>
<a href="#" class="node"><c:out value="${node.name}"/></a>
<c:set var="node" value="${node}" scope="request"/>
<jsp:include page="child.jsp"/>
</li>
</c:forEach>
I then have a jquery click event attached to the “.node” class of each href. When the href is clicked i want to be able have access to all the values in “node” in my Jquery click handler. What is the best way to do this? Thanks
You have few options available depending on what you want to do?
I normally use option 1 if all the data I need for the object is already being displayed on the page already to reduce the number of server calls.
Or option 2 if the object has extra fields you want to access in your but don’t need to display on the list to reduce the bloat in your HTML page.