Search code examples
javascriptjquerymodel-view-controllerjavascriptmvcejs

Reference to ejs view files does not change after the build, although it combines it inside of production.js - Javascript MVC


In the code we use something like this:

$('#wrapper').html('//app/views/content.ejs', {foo:"bar"});

And when we build the app, this still stays the same, although the content.ejs file is built into production.js.

So my question is, what should we do so that when we build the app, these references point to ejs files inside of production.js?

We are using JMVC 3.2.2

We've also tried using this way:

$('#wrapper').html( $.View('//app/views/content.ejs', {foo:"bar"}) );

Solution

  • Got the answer in JMVC forum: https://forum.javascriptmvc.com/topic/#Topic/32525000000958049

    Credit to: Curtis Cummings

    Answer:

    The paths to the views do not need to change.

    When the production.js file is created, your views are included and get preloaded when the script runs. When you reference: '//app/views/content.ejs', view first checks if the view file you are requesting has been preloaded and if it has, will use that instead of making a request for the .ejs file.