0

我有以下问题:我想通过 bindAttr 禁用我的按钮。所以我有这个按钮:

<div class="pull-right refresh-button" style="margin-top: -45px;" 
  title="update Items" {{action refreshItems target="view"}} {{bindAttr 
     disabled="ItemState.isDisable"}}>
  <i class="icon-refresh"></i>
</div>

其中 ItemState.isDisable 它是我用于状态的余烬对象。主要思想是当用户单击按钮时,在信息从服务器返回之前无法再单击...

我正在使用 ember RC6 和车把 RC4

有任何想法吗?

谢谢

4

1 回答 1

1

有不同的方法可以做到这一点,但最正确的方法可能是为您的按钮定义一个视图并在那里放置一些逻辑来处理状态。

例如:

MyButton = Ember.View.extend({
  attributeBindings: ['disabled'],
  disabled: function(){
    if (someLogic) {
      return true;
    } else {
      return false;
    }
  }.property()
});

让我知道是否清楚。

您可能会发现这个答案也很有用。

于 2013-07-04T14:23:35.230 回答