Input helper valueBinding is deprecated - what's the alternative?

大憨熊 提交于 2019-12-10 10:02:09

问题


I've got a few text-input helper like this

{{input type="text" valueBinding="name" focus-out="focusOutName"}}

I just upgraded Ember to 1.11.0 and now get this deprecation warning:

DEPRECATION: You're attempting to render a view by passing valueBinding to a view helper, but this syntax is deprecated. You should use value=someValue instead.

However when using value it is not bound in the controller and value simply sets the text to whatever value.

How do I correctly bind it?


回答1:


You should just have to change:

{{input type="text" valueBinding="name" focus-out="focusOutName"}}

to:

{{input type="text" value=name focus-out="focusOutName"}}

or even better (don't need the type="text", it's automatic):

{{input value=model.name focus-out="focusOutName"}}

then next to it you can display the value, and see it change when you change the input (so you can test for yourself that the bindings are set up already):

{{input value=model.name focus-out="focusOutName"}}
{{model.name}}


来源:https://stackoverflow.com/questions/29395693/input-helper-valuebinding-is-deprecated-whats-the-alternative

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