我的moorainbow colorpicker在ajax调用后不再起作用了... 我的页面第一次加载时效果很好:
<script type="text/javascript">
addColorPicker();
function addColorPicker(){
window.addEvent('domready', function() {
var r = new MooRainbow('myRainbow', {
'startColor': [255, 0, 0],
'onChange': function(color) {
$("editForm:colorpicker").value = color.hex;
}
});
});
}
</script>
但是当我进行ajax调用时:
<h:form id="fieldsForm">
<h:selectOneMenu id="fields" value="#{labelController.type.template.fieldConfig.editingField}">
<f:ajax render=":editForm" onevent="reAddColorPicker"/>
<f:selectItems value="#{labelController.fieldKeuzes}"/>
</h:selectOneMenu>
</h:form>
然后我调用reAddColorPicker:
<script type="text/javascript">
function reAddColorPicker(e){
if(e.status == 'success'){
window.addEvent('domready', function() {
var r = new MooRainbow('myRainbow', {
'startColor': [255, 0, 0],
'onChange': function(color) {
$("editForm:colorpicker").value = color.hex;
}
});
});
}
}
</script>
但是当我点击img打开颜色选择器时,我无法选择任何颜色,只有静态图像......