将名称属性添加到Ember.TextField? [英] add a name attribute to a Ember.TextField?

查看:85
本文介绍了将名称属性添加到Ember.TextField?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个漫长的一天,这可能是非常简单的,但是如何添加一个名称属性到Ember.TextField?



我想做这样的事情:

  {view Ember.TextField valueBinding =your_nameplaceholder =Your namename =your_name}} 

与占位符配合使用,但忽略名称。



任何想法?



谢谢
Rick

解决方案

p> name属性未被默认绑定,请参阅



作为解决方法,您可以创建自己的 TextField ,请参阅 http://jsfiddle.net/fkPzr/

  App.TextField = Ember.TextField.extend({
init:function(){
this._super();
//获取attributeBindings并添加'name'
var attributeBindings = this.get('attributeBindings');
attributeBindings.pushObject('name');
this.set('attributeBindings',attributeBindings);
}
});






更新



由于 attributeBindings 被声明为连接属性 *可以简化TextField,请参阅 http://jsfiddle.net/cRhcg/

  App.TextField = Ember。 TextField.extend({
attributeBindings:['name']
});

*连接的属性不会覆盖扩展对象的属性,而是覆盖超级对象的现有值被连接起来说得通?以下是示例


Its been a long day and this is probably extemely simple but how do i add a name attribute to a Ember.TextField ?

I want to do something like this :

{view Ember.TextField valueBinding="your_name" placeholder="Your name" name="your_name"}}

This works with the placeholder but ignores the name.

Any ideas ??

thanks Rick

解决方案

The name attribute is not bound by default, see

As a workaround, you could create your own TextField, see http://jsfiddle.net/fkPzr/

App.TextField = Ember.TextField.extend({
    init: function() {
        this._super();
        // get attributeBindings and add 'name'
        var attributeBindings = this.get('attributeBindings');
        attributeBindings.pushObject('name');
        this.set('attributeBindings', attributeBindings);
    }
});


​UPDATE:

Since attributeBindings is declared as a concatenated property* the TextField can be simplified, see http://jsfiddle.net/cRhcg/:

App.TextField = Ember.TextField.extend({
    attributeBindings: ['name']
});

*a concatenated property does not override the property of an extended object but the existing values from the super object are concatenated. Makes sense? Here's an example

这篇关于将名称属性添加到Ember.TextField?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆