> Speelmon, Lance Day wrote: >> >> As a Sling newbie, could someone help me understand when currentNode gets >> initialized in an esp file? The following script shows that currentNode is >> undefined in the $(document).ready context, but is defined later(?) within >> the <h1> tags. Thanks, L
2009/7/29 Branden Visser <bran...@uwindsor.ca>: > 'currentNode' is only accessible through server-side JavaScript. > > Your first access of currentNode is client-side, and therefore is undefined. As Branden says, currentNode is a server-side variable, but it's sometimes handy to have the full object available client side. To do so, you can include currentNode's JSON rendering: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> [...] <script type="text/javascript" charset="utf-8"> // Client-side javascript var currentNode = <% // Server-side javascript: sling.include(currentNode.path + ".json"); %>; // Client-side javascript alert("currentNode: " + currentNode.path); </script> [...] -- Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no Akersgata 16, N-0158 Oslo, Norway +47 21 531941, ext 2070