Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Backbone Set Model In View

    app.Todo = Backbone.Model.extend({
      defaults: {
        title: '',       
      }
    });
    // renders the full list of todo items calling TodoView for each one.
    app.AppView = Backbone.View.extend({
      el: '#todoapp',
      initialize: function () {
this.$el.html(this.model.get("title"));
      }
    });
    //--------------
    // Initializers
    //--------------   
var first = new app.Todo();
first.set("title", "HELLO WORLD");
console.log(test.get("title"));
    app.appView = new app.AppView({model: first}); 
 
PREVIOUS NEXT
Tagged: #Backbone #Set #Model #In #View
ADD COMMENT
Topic
Name
9+9 =