i trying save model, can save first model fine, if save 1 model , straight afterwards - following error,
uncaught typeerror: object [object object] has no method 'call'
what causing error?
my save code looks this,
groupmodalheaderview.prototype.save = function(e) { var $this = this; this.collection = new app.groupcollection(); if(this.$("#group-name").val() !== "") { this.collection.add(this.model,{ merge: true }); } this.model.save({ name: this.$("#group-name").val(), async: false, wait: true }, { success: function() { var grouplist = new app.grouplistview({ model: $this.model, collection: $this.collection }); var modal = new app.groupmodalview({ model: $this.model, collection: $this.collection }); $this.collection.on("change", grouplist.render(), this); $this.collection.on("change", modal.render(), this); //return $this.cancel(); } }); }; and model code looks this,
(function() { var group, groupsearchmodel, __hasprop = {}.hasownproperty, __extends = function(child, parent) { (var key in parent) { if (__hasprop.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; group = (function(_super) { __extends(group, _super); function group() { return group.__super__.constructor.apply(this, arguments); } group.prototype.urlroot = config.base + "api/group/groups"; group.prototype.defaults = { user_id: "", name: "new group", email: "", url: "", telephone: "", mobile: "", fax: "", people: "" }; group.prototype.idattribute = "id"; return group; })(app.basemodel); groupsearchmodel = (function(_super) { __extends(groupsearchmodel, _super); function groupsearchmodel() { return groupsearchmodel.__super__.constructor.apply(this, arguments); } return groupsearchmodel; })(app.basemodel); this.app = window.app || {}; this.app.group = group; this.app.groupsearchmodel = groupsearchmodel; }).call(this); i assuming has .call(this) @ end of model?
there's bunch of whackiness in code, first guess mistake causing current problem. when binding event handlers, want reference not excute handler function. instead of grouplist.render() (with parenthesese) executing function, want grouplist.render (without parenthesese) referencing without execution.
$this.collection.on("change", grouplist.render, this); $this.collection.on("change", modal.render, this); //return $this.cancel();
Comments
Post a Comment