Transform your code from:
define(['backbone', './model', './mySync'], function(Backbone, Model, mySync) {
var Collection = Backbone.Collection.extend({
model: Model,
sync: mySync| var Status = Backbone.Model.extend({ | |
| url: '/status' | |
| }); | |
| var Statuses = Backbone.Collection.extend({ | |
| model: Status | |
| }); | |
| var NewStatusView = Backbone.View.extend({ | |
| events: { |
| $(document).ready(function() { | |
| $('#new-status').submit(function(e) { | |
| e.preventDefault(); | |
| $.ajax({ | |
| url: '/status', | |
| type: 'POST', | |
| dataType: 'json', | |
| data: { text: $(this).find('textarea').val() }, | |
| success: function(data) { |
| $('form').bind('submit', function() { | |
| alert('User submitted form'); | |
| }); |
| -var events = _.clone(Backbone.Events); | |
| - | |
| var Status = Backbone.Model.extend({ | |
| url: '/status' | |
| }); | |
| -var Statuses = function() { | |
| -}; | |
| -Statuses.prototype.add = function(text) { | |
| - var status = new Status(); |
| var events = _.clone(Backbone.Events); |
| Uncaught TypeError: Cannot call method 'add' of undefined |
| var events = _.clone(Backbone.Events); |
| var Message = Backbone.Model.extend({ | |
| parse: function(resp) { | |
| resp.replies = new Messages(resp.replies); | |
| return resp; | |
| }, | |
| toJSON: function() { | |
| var attributes = _.clone(this.attributes); | |
| // evt: var attributes = Backbone.Model.prototype.toJSON.call(this) |
| // simpler render | |
| render: function() { | |
| var els = _.map(this._views, function(subview) { | |
| return subview.render().el; | |
| }); | |
| this.$el.empty().append(els); | |
| } |
Transform your code from:
define(['backbone', './model', './mySync'], function(Backbone, Model, mySync) {
var Collection = Backbone.Collection.extend({
model: Model,
sync: mySync