[Answered ]-Create model instance from non-JSON server response in Backbone.js

2πŸ‘

βœ…

I don’t think you should be loading templates in a model. The loading and rendering of templates would usually be the job of the view. Try loading the HTML directly with AJAX in the render method of your view:

 var ItemView = Backbone.View.extend({
  render: function(){
    var that = this;
    $.get('/item/123', function(html){
      that.$el.html(html);
    });
    return this;
  }
});
πŸ‘€net.uk.sweet

0πŸ‘

If you havent already, have a look at the django-app Tastypie, its the go-to solution for backend to backbone and similar apps.

Without seing the code its hard to tell how much work it would be to move it all into Tastypie vs rolling your own solutions on a per-case basis, look over the documentation.

πŸ‘€krs

Leave a comment