Prior to version 1.4, the Discovery Framework used jQuery 1.2.6, which is the version of jQuery supplied by Liferay. jQuery was available in the jQuery variable.
<script type="text/javascript"> jQuery.ready(function(){ myVar = "hello world!"; }) // postRender override function function postRender<portlet:namespace/>(asyncObject) { asyncObject.initAsync(); var detailLinks = jQuery('#<portlet:namespace/>async a .my-special-links'); detailLinks.expire(); detailLinks.livequery('click', function(e) { alert(myVar); }); } </script>The following example shows the Discovery Framework 1.4 (and later) syntax, with the relevant line highlighted:
<script type="text/javascript"> jq14.ready(function(){ myVar = "hello world!"; }) // postRender override function function postRender<portlet:namespace/>(asyncObject) { asyncObject.initAsync(); var detailLinks = jq14('#<portlet:namespace/>async a .my-special-links'); detailLinks.click( function(e) { alert(myVar); }); } </script>
<script type="text/javascript"> function myCustomFunction(asyncObject) { jq14('#myElement').append(myNewForm); // adds a new form to the document asyncObject.rewriteForms(); // after adding, must trigger rewriteForms } </script>
Although it is not required, Endeca recommends that you update your components' JavaScript code to use jQuery 1.4.4 through the jq14 variable instead of jQuery 1.2.6 through the jQuery variable, in order to gain the newer version's performance and functionality enhancements.