ember.js - Setting Ember js checkbox checked value based on if the current id exists in a hasMany relationship -


I am working on a small bill-sharing app.

I have a bill model which is responsible for many ('people') who is a user model in which there are many ('bills'). And in a Bill Group model there are so many connections for the two previous models.

I want to create a form to edit the bill. I use #each for both items in BillGroup I have a bill and a person, and I want to check the box if the person Present in the bill I have made a Jsbine to clarify my problem.

Thanks.

Due to this fact, you present a very difficult problem that your model does not match the template you want This is especially true because handlers do not support conditional ISS etc.

One way that you confuse the model to look like your template.

  Back This.store.find ('billGroup', 1). Then (function (records) {var usersPromise = record.get ('user'), bill promotion = record.get ('bill'); return Em.RSVP.hash ((user: user promos, bill: billspromos})} }. (Function (model) {var responsibles = Em.RSVP.all (model.bills.getEach ('responsibles'); Return responsibles.then (function () {Return model;})}}). (Function Model) {var ret = []; model.bills.forEach (function (bill) {var item = []; model.users.forEach (function (user) {Var ub = App.UserBill.create ({user: user , Bill: Bill}); Item Push (ub);}); Rated Push (Item);}); Return Rit;});   

this My opinion is quite painful, and hardly suited for asynchronous. I think it would be easy to set up a custom view that is aware of the user / bill in that scope.

See < / H3>
  App.FooView = Em.View.extension ({isResponsible: function} {var responsibles = this.get ('bill.responsible'); if (responsibles) {console.log ( Responsibles.indexOf (this.get ('user')) Return policies .indexOf (this.get ('user')) = 0;} Return false;}. Property ('bill.responsible. @ Each.id', 'user.id') //) for debugging only)}; <{Code}  

Template
  {{# view.FooView billed = bill user = user}} {{input type = "checkbox" name = "responsible" check = View.isResponsible}} {{user.name}} {{/ view}}   



Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -