Skip to content

Filesystem

Tim Branyen edited this page Nov 13, 2013 · 6 revisions

The Backbone Boilerplate has been designed to work well with and without a server. If you are using it within Adobe Air or PhoneGap, for instance, you will not have a server to run it through.

Note: If you are using it without a server, make sure you have permissions to do local AJAX requests, otherwise you should switch to using inline templates to avoid having to make an AJAX request

You will need to update the root property on the app object, disable pushState, and update the paths inside index.html.

First set the app root to an empty string so that the application will reference the local directory. This property exists in app/app.js.

// The root path to run the application through.
app.root = "";

After you have updated the root, update index.html to make asset paths relative.

<!-- Application styles. -->
<!-- build:[href] styles.min.css -->
<link rel="stylesheet" href="app/styles/index.css">
<!-- /build -->

<!-- Application source. -->
<!-- build:[src] source.min.js -->
<script data-main="app/main" src="vendor/bower/requirejs/require.js"></script>
<!-- /build -->

Lastly ensure that pushState is disabled, as this is not supported without a compatible server. This option is located in app/main.js.

// Trigger the initial route and enable HTML5 History API support, set the
// root folder to '/' by default.  Change in app.js.
Backbone.history.start({
  pushState: false,
  root: app.root
});