Emberjs how to bind-attr an id

半世苍凉 提交于 2019-12-12 05:59:38

问题


I want to use ember properties to toggle the visibility of a div by calling it's dynamic id, however even though I can do something similar by calling classes, I cannot do the same for id's.

For example: {{bind-attr class=":class1 controller.controllerProperty:class2"}} works fine. I can toggle the controllerProperty from an action in my controller.

You would think the same concept would apply to id's. However {{bind-attr id=":staticId controllerProperty:id{{dynamicIdNumber}}"}} makes the id's disappear all together!

Why is this happening and what is the correct method to be doing this sort of this? I would like to avoid work-around solutions as much as possible.


回答1:


Binding to classes is a special case in Ember as described in here Binding the other attributes to properties is described here



来源:https://stackoverflow.com/questions/26806067/emberjs-how-to-bind-attr-an-id

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