Search code examples
codeigniterbackbone.js

Is it possible to use backbone for multi page web apps?


I need to use RESTful API for a codeigniter project and looking to use backbone.js I want to know is it possible to use backbone.js for multi page web application. Does that meet good coding practices?


Solution

  • Yes, of course you can build non single page application using backbone js. This library is all about keeping your code in order. It does not enforce any architecture.

    In that case you do not need backbone router and you can simply render given view related to given page.

    For example, whenever user is on /about page you can attach about.js with content similar to following:

    const view = new (Backbone.View.extend({
       render() {
          return 'My about page';
       }
    })); 
    
    view.render({
       el: $('.contact-page__content')
    });