【发布时间】:2012-12-12 02:44:10
【问题描述】:
我尝试从 http://www.eyecon.ro/bootstrap-colorpicker/ 包装一个 colorPicker 组件
我需要用视图的“值”属性填充模板的“背景颜色 css 属性”...
我尝试设置 {{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"}}
【问题讨论】:
-
试试 valueBinding="view.value" 而不是 "this.value"
-
使用 view.value 我得到以下结果:
-
你能发个小提琴什么的吗,因为这样很难调试!
-
我的第一个 github :) github.com/fvisticot/colorpicker.git
标签: ember.js