handlebars.js - ember.js attribute binding and the event object -


so far, looks ember not work expected, , i'm hoping i've missed something. need iterate on model, blob of json made of arrays , objects, , build out form. when user marks checkbox, controllers action updates model.

here's how want work...

  <form {{action 'answersupplied'}}>     {{#each model.questions}}       <h3>{{text}}</h3>          {{#each answers}}             {{input type='../type' answerid='id' data-bind-questionnum='../id' text}}         {{/each}}      {{/each}}   </form> 

here's how can close that...

  <form {{action 'answersupplied' this}}>     {{#each model.questions}}       <h3>{{text}}</h3>          {{#each answers}}             {{formbuilder ../type id ../id text}}         {{/each}}      {{/each}}   </form> ================== handlebars.registerhelper('formbuilder', function(type, id, qnum, text, options) { //    console.log(options);      var q_type = options.contexts[0][type],         a_id = options.contexts[1].id,         q_number = options.contexts[0][qnum],         a_text = options.contexts[1].text;          return new handlebars.safestring(                 '<input type='+ q_type +' id='+ a_id +' name='+                     q_number +'>'+ a_text + '</input><br/>'         );     } }); 

the big problem wit is, can not identify element clicked because don't have access event object.

can manually bind action 'data-ember-action', , pass in params? or, far outside ember way?

== update ==

here's above jsfiddle, improved passing parameters action. event propagation seems halted in action resulting in inputs not getting marked. radio buttons loose grouping, , checkboxes not checked.

ember can handle you're doing here. first it's easier keep scope , generate named each loops.

 <form {{action 'answersupplied'}}>     {{#each question in model.questions}}       <h3>{{question.text}}</h3>          {{#each answer in question.answers}}             {{input type=question.type answerid=answer.id data-bind-questionnum=question.id placeholder=answer.text}}         {{/each}}      {{/each}}   </form> 

you may have if statements labels etc around input statements.

http://emberjs.jsbin.com/zofoqeje/1/edit


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -