javascript - Edit one line in #each block -
i have template:
{{#each action_log}} <div> {{name}} {{#if editing_score}} <input type="text" id="set_score" parm="{{_id}}" value="" /> {{else}} <div class="score" id="{{_id}}">{{score}} .</div> {{/if}} </div> {{/each}} and have javascript code:
session.set('editing_score', false); template.today_list.editing_score = function() { return session.equals('editing_score', true); }; template.today_list.events({ 'click .score': function(e, t) { session.set('editing_score', true); session.set('editing_score_id', e.target.id); meteor.flush(); } }); so, user can see list of actions, want click on 1 of them , edit value. now, if user click on action, code display textboxes actions.
how can display textbox 1 action ?
i have action id in session:
session.set('editing_score_id', e.target.id); but can not this:
{{#if editing_score && editing_score_id == _id}} or
{{#if editing_score(_id)}} what best way ?
thanks in advance.
with template:
{{#if editing_score id}} with helper:
template.today_list.editing_score = function(id) { return session.equals('editing_score_id', id); }; however, refactor bit have 1 session variable — no need two.
also, 'click .score' passes context, can id this — find more reliable mucking around event passing in.
Comments
Post a Comment