Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing RequireJS and Backbone across different pages in a CodeIgniter web app
    primarykey
    data
    text
    <p>I'm building a web app with CodeIgniter in the back and Backbone/RequireJS in the front. As such, it's not a single page web app, but rather still uses CI for a lot of the controller actions, and Backbone for various views at different times. I have RequireJS/Backbone setup like this:</p> <pre><code>&lt;script type="text/javascript" data-main="main" src="require.js"&gt;&lt;/script&gt; </code></pre> <p>main.js looks like: </p> <pre><code>require.config({ paths: { jquery: "https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min", underscore: "libs/underscore", backbone: "libs/backbone", //Lots of other stuff }, shim: { backbone: { deps: ["underscore", "jquery"], } // lots of other stuff } }); require(['views/app'], function(AppView){ var app_view = new AppView; }); </code></pre> <p>Main.js is loaded in my master template i.e. on every page, and in turn loads a bunch of views that are common throughout the site/app - header, navs, etc.</p> <p>But on different pages I also want to load different views in addition to the common ones. So, for example, on a page called 'publish' - almost an app in itself - I do:</p> <pre><code>&lt;script type="text/javascript" src="publish.js"&gt;&lt;/script&gt; </code></pre> <p>Which is loaded after main.js and looks like:</p> <pre><code>//publish.js require(['views/publishview], function(PublishView){ var publishView = new PublishView; }); </code></pre> <p>Basically, it works half the time, and the other half (when I hammer refresh) I get 404s on everything.</p> <p>So is there a neat way to use my basic require config for everything, but also require different parts at different times? It seems easy enough to do if the the whole thing was an SPA, but for me, a large part of the app is still with CodeIgniter.</p> <p>Sorry for not phrasing this better.</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