【发布时间】:2015-03-15 15:58:28
【问题描述】:
我正在将颜色选择器实现到构建器中。 http://colpick.com/plugin 选择的颜色存储在数据库中。检索后,它不会反映颜色选择器上的真实颜色。相反,颜色选择器设置默认值。此外,它不记得页面重新加载后的颜色。
任何帮助将不胜感激。
这是我们用来调出选择器并保存颜色值的代码:
<script>
set_field_visibility();
$('.picker').colpick({
flat: true,
layout: 'hex',
submit: 0,
onChange: function(a, hex, c, element, e) {
var id = $(element).attr('id') + '_color';
console.log(id);
$('#' + id).val('#' + hex);
}
});
</script>
这是我尝试过的,但仍然没有运气。
$('#picker').colpick({
layout:'hex',
submit:0,
colorScheme:'dark',
onChange:function(hsb,hex,rgb,el,bySetColor) {
$(el).css('border-color','#'+hex);
// Fill the text box just if the color was set using the picker, and not the colpickSetColor function.
if(!bySetColor) $(el).val(hex);
}
}).keyup(function(){
$(this).colpickSetColor(this.value);
});
【问题讨论】: