Note that there are some explanatory texts on larger screens.

plurals
  1. POAccount for Backbone.js pushState routes with node.js express server?
    primarykey
    data
    text
    <p><code>pushState</code> support was introduced with Backbone.js' version 0.5 update.</p> <p>From <a href="http://documentcloud.github.com/backbone/#History">the backbone documentation</a>:</p> <blockquote> <p>Note that using real URLs requires your web server to be able to correctly render those pages, so back-end changes are required as well. For example, if you have a route of /documents/100, your web server must be able to serve that page, if the browser visits that URL directly. For full search-engine crawlability, it's best to have the server generate the complete HTML for the page ... but if it's a web application, just rendering the same content you would have for the root URL, and filling in the rest with Backbone Views and JavaScript works fine.</p> </blockquote> <p>This may seem like a trivial question, but I'm wondering if anyone can help me with some specific (preferably <a href="http://expressjs.com">express</a>) <a href="http://nodejs.org">node.js</a> server code. How should I go about handling these routes? I'm a little confused.</p> <p>Here's the relevant excerpt from my app's router module:</p> <pre><code>var Router = Backbone.Router.extend({ routes: { '': 'index', 'about': 'about' }, index: function() { indexView.render(); }, about: function() { aboutView.render(); } }); var initialize = function() { var router = new Router; Backbone.history.start({ pushState: true }); } return { initialize: initialize }; </code></pre> <p>I only have a top-level route and a route for an about page here. So how should I set up a node server that will allow me to navigate to:</p> <pre><code>domain.com domain.com/about domain.com/#/about // &lt;- for browsers that don't support pushState </code></pre>
    singulars
    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.
 

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