dimanche 15 février 2015

Removing item from array not working


I'm trying to remove a tag from an array. But I can't get it to work – nothing happens. The console.log output seems to be correct. Thanks!


The event handler



Template.doc.events({
'click .remove': function(event, template) {
console.log("This doc's _id: " + template.data._id);
console.log("doc's tags: " + template.data.metadata.tags);

var thisTag = this;
console.log("thisTag: " + thisTag);

MyPix.update (
template.data._id,
{ $pull: { 'template.data.metadata.tags': thisTag }},
{ multi: true }
);
},
});


The Template



<template name="doc">
<ol><li>
<span class="property">metadata.tags</span>:
{{#each this.metadata.tags}}
<span class="tag"><span class="remove">X</ span>{{this}}</span>
{{/each}}
</li></ol>
</template>




Aucun commentaire:

Enregistrer un commentaire