Jump to content

Javascript load order problem


Rob
 Share

Recommended Posts

I am having a problem with my module code that seems to be loading my module JS code BEFORE the JQuery libraries and therefore I am getting a '$ is not defined' error.

The weird thing is that I have used the exact same module code in a previous module and it loaded the module JS AFTER the JQuery so it worked fine, but in this case it is not working.

public function init() {
 parent::init();

 // add necessary admin page scripts
 // ---------------------------------------------------------------------------------
 $this->config->styles->append( $this->config->urls->ProcessTestSearch . "css/demo_table.css" );
 $this->config->styles->append( $this->config->urls->ProcessTestSearch . "css/demo_table_jui.css" );
 $this->config->scripts->append( $this->config->urls->ProcessTestSearch . "js/dataTables/jquery.dataTables.min.js");
 //$this->config->scripts->append( $this->config->urls->ProcessTestSearch . "js/dataTables/dataTables.fnSetFilteringDelay.js" );
 $this->config->scripts->append( $this->config->urls->ProcessTestSearch . "ProcessTestSearch.js" );
}

Is there something I am doing wrong? Is there some way to control the order in which modules output the JS script links into the header? I presume this must be happening because, for some reason, the core JQuery module is being loaded after my module, and so therefore the scripts are being added after my module scripts.

Link to comment
Share on other sites

No, there's no way to exactly define order, but if done right it should load after jquery core.

Can you show full module code? It depends on more than just the init. What type etc...

Edit:

Also see here :

And here :

And here :

Link to comment
Share on other sites

Thanks Soma.

Turns out it was the autoload status which had originally, by accident, been set to true and despite changing it back to false the code it was saved in the DB. I have changed it in the DB and now it seems to work.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...