Ember:绑定布尔元素属性不起作用?

时间:2013-03-16 16:26:50

标签: binding attributes ember.js

试图从Guide开始做布尔“绑定元素属性”。

javascript是:

window.App = Ember.Application.create();

window.App.NumberTextField = Ember.TextField.extend({
  valueChanged: (function() {
    return this.get("controller").set("isNotCompleteId", this.get("value").length !== 6);
  }).observes("value")
});

window.App.LandingController = Ember.ObjectController.extend({
  isNotCompleteId: true
});

window.App.Router.map(function() {
  return this.route("landing", {
    path: "/"
  });
});

模板是:

<h3>Example:</h3>
<script type="text/x-handlebars">    
<p>
    <a href="#"
       {{bindAttr disabled="isNotCompleteId"}}>
         Join number:
    </a>
    {{view App.NumberTextField valueBinding="idEntered" size="8"}}

    <p>{{idEntered}}</p>
</p>

</script>

这个jsfiddle显示(我认为是)不良行为:http://jsfiddle.net/csterritt/AaTpd/11/

在“结果”窗格中检查“加入号码:”链接。它没有“禁用”属性(我相信它应该)。更改文本框中的文本直到它有六个字符不会更改属性(它应该是六个字符)。

如果我将HTML的第7行更改为{{bindAttr class =“isNotCompleteId:foo:bar”}},它将按预期工作(尽管该类以“bar”开头,因此,控制器属性甚至以false开头虽然我把它设置为真...... ???)。

错误?我的困惑?

谢谢!

0 个答案:

没有答案
相关问题