#ember-power-select: changing the value in one power-select box , it alternately changes the same value for another power-select box

半城伤御伤魂 提交于 2019-12-02 20:32:53

问题


I used custom-search-action in #ember-power-select, changing the value in one power-select box , it alternately changes the value(sets the same value as selected in 1st select box)for another power-select box too.

Below is the handlebar code:

{{#each model.hpqualifications as |hpqualification|}}
{{#power-select
  selected=hpqualification.hoprofile
  search=(action "hoProfile")
  onchange=(action (mut hpqualification.hoprofile.name) value="name")
  as |repo|
}}
  {{repo.name}}
{{/power-select}}
{{/each}}

The above code generated two select box since #each method has two data.

Everything works fine. But when selecting the value from dropdown for 1st select box, the 2nd select box too changes to the same value.

How to fix this ?

Please refer to my previous stackoverflow question for other files and data format.


回答1:


You issue is this (action (mut hpqualification.hoprofile.name) value="name")

This will actually change the name of the current selected hoprofile object. Which means, that now you could potentially have two objects with a same name.

If you change it back to (action (mut hpqualification.hoprofile)), that will actually change the object that is selected.

Now I don't know what the end result you are trying to get, but I think this is you problem.



来源:https://stackoverflow.com/questions/37656662/ember-power-select-changing-the-value-in-one-power-select-box-it-alternately

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!