i trying access individual document within #each in meteor can mark it. if user clicks on content want run logic on document. example:
{{#each document}} <div> {{text}} {{did_i_read_the_doc}} </div> {{/each}} and want {{did_i_read_the_doc}} show "yes" or "no" depending on whether marked in collection. in template helper want like
template.documents.helpers({ did_i_read_the_doc: function() { //what goes here? if (thisindividualdocument.contains(meteor.userid() in "readby") show "yes" in html else show "no" in html } i'm not sure how access individual mongo document in helpers wrapped in each block. i'm used logic of returning of documents in helper documents: function() { return documents.find({}) }
but how define helper function gets individual document? in final run of things want able click document , mark read, notification, , have shows saying "already read" or "unread" depending.
i figured out right after posted.
in helper method can use
my: function() { if(this.field) //do so 'this' grabs individual document.
edit: example solve specific case
did_i_read_the_doc: function() { if(this.read) { return "yes" } else { return "no" } }
Comments
Post a Comment