将名称属性添加到Ember.TextField? [英] add a name attribute to a 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屋!