$(function () { // Create a model class. const TodoItem = Backbone.Model.extend({ // RESTful web service, RoR flavor. urlRoot: '/server/todos' }); // Create a model instance to load it by ID. const todoItem = new TodoItem({ id: 1 }); // Access the server at /server/todos/1 (urlRoot + '/' + item.id). const x = todoItem.fetch({ async: false }); // Manipulate attributes. const description = todoItem.get('description'); todoItem.set('status', 'complete'); // Save on server. todoItem.save(); // Create a view class. const TodoView = Backbone.View.extend({ render: function () { const html = '

' + this.model.get('description') + '

'; $(this.el).html(html); } }); // Create a view instance. const todoView = new TodoView({ model: todoItem }); todoView.render(); $('#app').html(todoView.el); });