Backbone View - How can I pass 'this' through multiple functions?
This is from my Backbone View. But I keep getting the following error:
'Uncaught TypeError: Cannot call method 'add' of undefined'. How can I
keep this so that I can add a new model to my collection?
addGroupModal: function() {
$('#add-group-modal').modal('show');
// Manual Event Listener for Submit Button
$("#add-group-submit-button").click(function(){
var newGroup = new KAC.Models.KeepAContactGroup({ name: '123',
list_order: '2' });
console.log(newGroup)
newGroup.save();
this.collection.add(newGroup)
});
},
No comments:
Post a Comment