Is to make a "splice" in a value of "return" of the "Template"
Example:
Template.create.values = function () {
return [{
'value1': '1',
'value2': '2',
'value3': '3',
}];
};
Template.create.events({
'click #add': function () {
Template.create.values.splice(Template.create.values.length, 0, {
'value1': '1',
'value2': '2',
'value3': '3',
});
}
});
I'm doing a "each" in "Template.create.events", and automatically change the template?
Use a session variable or a reactive-dict instead. For example:
var DEFAULT_VALUES = {
'value1': '1',
'value2': '2',
'value3': '3'
};
Session.setDefault('createValues', DEFAULT_VALUES);
Template.create.values = function() {
// I'm assuming you need this in a template
return Session.get('createValues');
};
Template.create.events({
'click #add': function() {
var data = Session.get('createValues');
data.push(DEFAULT_VALUES);
Session.set('createValues', data);
}
});