How can I load a script in a JavascriptMVC controller

434 views Asked by At

I know how to load scripts using steal however I want to load it before the code in my controller's init method is executed. I need the methods from a script file to be defined before the controller initialization.

How can I do that?

EDIT: Some background info: I've tried loading the script file using the steal function in the controller like so:

steal( 'jquery/controller','jquery/view/ejs', '../js/other.js' )

The result was that the file was loaded via <script> tag in the head section of the file. Also jQuery was not defined before loading set file.

1

There are 1 answers

2
noah On BEST ANSWER

Are you using then() to define your controller?

steal('jquery/controller','../js/other.js').then(function() {
    // other.js is loaded now
    $.Controller(...);
});