我尝试从http://www.eyecon.ro/bootstrap-colorpicker/包装一个colorPicker组件
我需要用视图的"value“属性填充模板的"background-color css attribute”...我已经尝试设置{{value}},但它不起作用...
有什么建议吗?
JavaScript:
App.ColorPicker = Em.View.extend({
classNames: 'input-append color',
attributeBindings: ['name', 'value'],
value: '',
template: Ember.Handlebars.compile('{{view Ember.TextField valueBinding="this.value"}}<span class="add-on"><i style="background-color: {{value}}"></i></span>'),
didInsertElement: function() {
$('#backgroundColor').colorpicker({format: "rgb"});
}
})
;
html:
{{view App.ColorPicker placeholder="Background color" name="backgroundColor" valueBinding="App.controller" classNames="input-large" id="backgroundColor"}}
发布于 2012-12-27 10:30:39
您需要查看{{bindAttr}}
帮助器。在here上有一篇古老但很好的帖子
基本上,您不能简单地将绑定值放到HTML标记中,因为它会插入包装器脚本标记并破坏所有内容。
你要找的是:
App.ColorPicker = Em.View.extend({
classNames: 'input-append color',
attributeBindings: ['name', 'value'],
value: '',
template: Ember.Handlebars.compile('{{view Ember.TextField valueBinding="this.value"}}<span class="add-on"><i {{bindAttr style="view.iStyle"}}></i></span>'),
iStyle: function() {
return "background-color:" + this.get('value');
}.property('value'),
didInsertElement: function() {
$('#backgroundColor').colorpicker({format: "rgb"});
}
});
https://stackoverflow.com/questions/14042322
复制相似问题