[Answered ]-Is having Django and Backbone.js double templates avoidable?

1👍

Actually, you can write a single-page application and still support SEO. Backbone’s router accomplishes this by creating a separate URL for each state of the application. Your links throughout the application will be crawled. Google does a good job of crawling SPA’s these days. I believe your decision not to create your site as an SPA was influenced by stale opinion.

👤Tim

1👍

Basically you can do that, All you need to make sure is you don’t call render on views first time.

say my page has this html

<ul class="my-list">
 <li><a href="#">do something</a></li>
 <li><a href="#">do something</a></li>
 <li><a href="#">do something</a></li>
</ul>

initially you define a view

var MyView =  Backbone.View.extend({
  el:'.my-list',
  render:function(){
    this.collection.each(this.addItem, this);
  },
  addItem:function(){
    //do adding logic here
  }
})

instantiate using, but don’t call render

 var myView = new MyView({
    collection: myCollection //any collection or model you like here
 })

when ever you want to update the view, call myView.render then. By this you get the benefit of SEO and backbone both. I guess popular web applications like You Tube does follow similar approach (may not be using Backbone).

Leave a comment