Im using .Deps to track whether a template is in edit mode of view mode. I’ve got it working fine, apart from when I’ve saved the changes. It goes back to view mode fine, but then won’t let me switch back to edit. It seems that when the doc gets updated, it kills the dependancy. Each _exstandBlock is called in another template via a standard helper and #each
Any ideas?
Issue in the console:
Exception in template helper: TypeError: Cannot read property 'depend' of undefined
Here’s my code for reference:
Template._techpitchBlock.created = function() {
this.data.isEditing = false;
this.data.isEditingDep = new Deps.Dependency();
};
Template._techpitchBlock.helpers({
'editing' : function() {
this.isEditingDep.depend();
return this.isEditing;
},
});
Template._techpitchBlock.events({
//e = event
//t = template
'click .edit-techpitch': function(e, t) {
t.data.isEditing = true;
t.data.isEditingDep.changed();
},
'click .cancel-changes': function(e, t) {
t.data.isEditing = false;
t.data.isEditingDep.changed();
},
'click .save-changes': function(e, t) {
var techpitchId = this._id;
console.log(this);
var techpitch = {
name: t.find('[name=name]').value,
pitcher: t.find('[name=pitcher]').value,
description: t.find('[name=description]').value,
};
t.data.isEditing = false;
t.data.isEditingDep.changed();
Meteor.call('editTechpitch', techpitchId, techpitch);
},
});