ember.js - how to get the id of the object when using toggleProperty -


I would like to get the story object ID in the following templates so that I can comment but I am not sure how to do it. I would think that in the action there is a reference to that object which was called upon.

I have:

  {{#each}} & lt; Div & gt; {{Date}} & lt; / Div & gt; {{#each stories}} & lt; Div {{action 'toggleproperty' comments displayed '}} & gt; {{Headline}} {{url}} {{id}} & lt; / Div & gt; {{/ Each}} Finally {{/ every}} & lt; Br / & gt; & Lt; Br / & gt; {{#if areCommentsDisplayed}} Comments {{id}} {{else}} are displayed with comments {{id}} {{/ if}}  

are not displayed Action ID is not the reason for writing. In the Commands Display Block below. How do I get a reference to write that ID?

thx

This is because id now Each is not in the area outside the block. You need to assign an id to a variable, then show it. For example, I will change your action on this:

  {{togglecomments' id}}  

Then implement this kind of action:

Toggle comments: function (id) {this.set ('selectedId', id); This.toggleProperty ('areCommentsDisplayed'); }

Now you can use your if block in the selectedId , which will be within the scope and the most recent story in it You will click on the ID.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -