Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery, $(document).ready({--}), multiple functions and multiple files
    primarykey
    data
    text
    <p>I've been noticing some odd behavior when trying to implement a configuration javascript file to enable/disable user interface features based on development or production environment, and can use some clarification.</p> <p>This is a flat application, and I've split the javascript into three files: index.js, dashboard.js and taxonomy.js. </p> <pre><code>&lt;script type = "text/javascript" src = "/static/js/taxonomy.js"&gt;&lt;/script&gt; &lt;script type = "text/javascript" src = "/static/js/dashboard.js"&gt;&lt;/script&gt; &lt;script type = "text/javascript" src = "/static/js/index.js"&gt;&lt;/script&gt; &lt;script type = "text/javascript" src = "/static/js/config.js"&gt;&lt;/script&gt; </code></pre> <p>The index script handles the login, logout and element initialization functionality. Its defined as </p> <pre><code>$(document).ready(function(){ $.ajax({ //query db for login success : function(){ loginHandler() } }); function loginHandler(){ initializeDashboardElements() initializeTaxonomyElements() } </code></pre> <p>Inside taxonomy.js, there is no <code>$(document).ready()</code> definition, but <code>initializeTaxonomyElements()</code> exists, which applies jQuery UI bindings to the specified HTML elements. One such element is a tab widget that currently contains 4 tabs, but is expected to grow. </p> <p>Inside <code>config.js</code>, I have this for the production environment:</p> <pre><code>$(document).ready(function(){ $("#tabs").tabs("option", "disabled", [1, 2]); }); </code></pre> <p>Given this setup, I get an error</p> <pre><code>Error: cannot call methods on tabs prior to initialization; attempted to call method 'option' </code></pre> <p>I've also tried this with <code>initializeTaxonomyElements()</code> within a <code>$(document).ready()</code> declaration. The same error occurs.</p> <p>Any suggestions to resolve this issue?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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