javascript - Ember.js Handlebars bindings logical not - Stack Overflow

Is there a logical not for handlebars bindings with Ember.js?Suppose I have a ember view that I want to

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 plementary unless statement. handlebarsjs. – wmarbut Commented Aug 6, 2012 at 18:57
Add a ment  | 

1 Answer 1

Reset to default 9

Creating 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').

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745270641a4619724.html

相关推荐

  • javascript - Ember.js Handlebars bindings logical not - Stack Overflow

    Is there a logical not for handlebars bindings with Ember.js?Suppose I have a ember view that I want to

    7小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信