javascript - Emberjs filtered select collection update -



javascript - Emberjs filtered select collection update -

i made jsbin demonstrate problem:

http://jsbin.com/pexolude/69/edit

explonation:

in first select have customers. select's value (customer_value) filters 2nd select's (contactpersons) collection. if select customer, "new contact person" button enabled. on click adds new contact person "dale" double r diner. (in app form , new contact person add together selected customer)

the test

select "double r diner" add new contact person (dale added, not on double r diner's contact persons list ) change "great northen hotel" go "double r diner" -> dale on list

it nice have contact_persons property auto-updated when new element added. shouldnt default behaviour? or have trigger somehow?

totally, rule of thumb, @ of properties required in computed property, , if of them create difference in value of computed property (which i'd assume do), should defined in property method.

in case, want watch each property on collection, utilize @each keyword. it's of import note, can't go more 1 level deep @each. http://emberjs.com/guides/object-model/computed-properties-and-aggregate-data/

contact_persons: function(){ var id = parseint(this.get('customer_value'),10); homecoming this.get('contactpersons').filterby('partner.id',id); }.property('customer_value', 'contactpersons.@each.partner'),

what we're saying here time new record added/removed contactpersons, or partner property changes on of them (partner itself, not partner.foo, partner reference must change) property dirty.

example: http://jsbin.com/pexolude/72/edit

javascript ember.js

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -