admin管理员组文章数量:1417550
Is there a logical not for handlebars bindings with Ember.js?
Suppose I have a ember view that I want to bind to a value
{{Ember.Button disabledBinding="view.controller.some_value"}}
I only want the button to be disabled if some_value
is false
. The code above makes it disabled if some_value
is true
.
One approach to fixing this would be to have a plementary puted value on the controller. excuse my coffeescript
opposite_some_value: (->
if @get('some_value') == true
return false
else
return true
).property 'some_value'
But this seems clunky.
Is there a logical not for handlebars bindings with Ember.js?
Suppose I have a ember view that I want to bind to a value
{{Ember.Button disabledBinding="view.controller.some_value"}}
I only want the button to be disabled if some_value
is false
. The code above makes it disabled if some_value
is true
.
One approach to fixing this would be to have a plementary puted value on the controller. excuse my coffeescript
opposite_some_value: (->
if @get('some_value') == true
return false
else
return true
).property 'some_value'
But this seems clunky.
Share Improve this question asked Jul 26, 2012 at 16:16 wmarbutwmarbut 4,7057 gold badges45 silver badges76 bronze badges 1-
Handlebars supports the logical not in
if
statements through the plementaryunless
statement. handlebarsjs. – wmarbut Commented Aug 6, 2012 at 18:57
1 Answer
Reset to default 9Creating a property with the inverted value is the way to go. You can use binding helper for this: oppositeValueBinding: Ember.Binding.not('some_value')
.
Also note the Ember.Button
is deprecated and you should use the {{action}}
helper instead.
UPDATE
In newer versions of Ember.js, it's oppositeValue: Ember.puted.not('some_value')
.
本文标签: javascriptEmberjs Handlebars bindings logical notStack Overflow
版权声明:本文标题:javascript - Ember.js Handlebars bindings logical not - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745270640a2650869.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论