Changes

JQuery

1,048 bytes added, 02:23, 9 September 2013
no edit summary
If you wish to use jQuery you should include the following script tags within a [[Browser Script]] custom field, or on the [[Template Page]] if appropriate.
</pre>
You may encounter the situation where even after you have included the jQuery library in your code, possibly using the script above, you still recieve a '$ undefined' or 'jQuery undefined' error, when viewed in the browser console.
 
This means that the browser does not recognize the '$' or 'jQuery' reference, depending on which syntax you have used to access the jQuery object in your code.
 
This happens because the jQuery source code has not been loaded or completely loaded on the page when your script runs initially.
One way of rectifying this is to write your JavaScript code to repeatedly check to see if the jQuery library has been completely loaded and when that has happened you may then access the library using the jQuery object.
 
This can be implemented inserting the isjQueryLoaded function below in your code in addition to the script above:
 
<pre>
...
(function isjQueryLoaded(){
(window.$) ? myScript() : setTimeout(isjQueryLoaded, 100);
})();
 
function myScript(){
//tasks to be completed when jQuery is loaded...
}
...
</pre>
[[Category:JavaScript]]
6
edits