Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically loading jQuery and extensions
    primarykey
    data
    text
    <p>I'm trying to encapsulate a javascript that I built using jQuery, jQuery UI, jQuery Form and xmlDom.</p> <p>I want to be able to send to my client just one javascript that references the other ones, including just a small piece of js for options settings. </p> <p>Find below an example:</p> <pre><code>&lt;script language="javascript"&gt; var myOptions = { shop: 1, style: "gold" } load(); &lt;/script&gt; &lt;script src="http://myServer/myScript.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>It's been nearly impossible to me to load jQuery and plugins dynamically. I read a lot of examples, jQuery works fine when I load it dynamically, but the rest of the extensions never worked properly. Following sequence is the unique one that loaded at least a couple of plugins:</p> <p>Set a load function that loads jQuery dynamically:</p> <pre><code>load = function() { load.getScript(url_base + "/js/jquery-1.3.2.js"); load.tryReady(0); } load.getScript = function(filename) { var script = document.createElement('script') script.setAttribute("type","text/javascript") script.setAttribute("src", filename) if (typeof script!="undefined") document.getElementsByTagName("head")[0].appendChild(script) } load.tryReady = function(time_elapsed) { // Continually polls to see if jQuery is loaded. if (typeof $ == "undefined") { // if jQuery isn't loaded yet... if (time_elapsed &lt;= 5000) { // and we havn't given up trying... setTimeout("load.tryReady(" + (time_elapsed + 200) + ")", 200); // set a timer to check again in 200 ms. } else { alert("Timed out while loading jQuery.") } } else { ... } </code></pre> <p>Load every plugin after that, jQueryForm, jQuery UI, xmlDom</p> <p>When I check for jQuery form it's available:</p> <pre><code>if (jQuery().ajaxForm) </code></pre> <p>When I check for xmlDom it works.</p> <p>When I check for jQuery UI it's never available.</p> <pre><code>if(jQuery().ui) </code></pre> <p>It doesn't matter if I set a timeout to wait for UI, it's never loaded. Seems to be jQuery executes my UI features before it's loaded.</p> <p>Can anybody send me a link to help with this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload