简体   繁体   中英

How can be set the ember.js input name by model attribute?

I have a tabular form created in emberjs. I need to set the inputs name but it doesn't work.

my model:

Items.Item = DS.Model.extend({
   title: DS.attr('string'),
   itemName: function() {
       return 'Item['+ this.id +'][title]';
   }
});

my original input

<td>{{input name="Item[][title]" value=qty}}</td>

and the code with the itemName:

<td>{{input name=itemName value=qty}}</td>

This doesn't work for me. if I put the itemName to the value attribute, it works, but with the name doesn't.

How can I set the name attribute?

It would be also good for me to set the name of the items in each loop with the {{@index}} .

ok, i have modified the model this way:

itemName: function() {
   return 'Item['+ this.id +'][title]';
}.property()

and everything works...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM