Avanox
March 29, 2011, 12:13pm
#1
i’m trying to attach the colorpicker to an input field from an xml file but I can’t get it to work…
here’s the javascript:
var instNogietsForm = dhxAccord.cells("inst_Event_color").attachForm();
instNogietsForm.loadStruct("inc/xml/forms/inst_agenda_eventcolor_struct.php",function() {} );
myCP = new dhtmlXColorPickerInput("colorPicker");
myCP.setImagePath("codebase/imgs/");
myCP.init();
and here’s the xml:
echo '<item type="input" id="colorPicker" name="colorPicker" value="Hier"/>';
But this doesn’t load the colorPicker. How can I make it work ?
Form doesn’t set ids for html inputs.
Therefore, you need to define method that returns input object:
dhtmlXForm.prototype.items.select.getInput=function(item){
return item.childNodes[1].childNodes[0];
};
When this method is defined, you may apply the following:
instNogietsForm.loadStruct("inc/xml/forms/inst_agenda_eventcolor_struct.php",function() {
var inputObj = instNogietsForm.doWithItem("colorPicker", "getInput");
myCP = new dhtmlXColorPickerInput(inputObj);
...
} );
Avanox
March 29, 2011, 12:58pm
#3
ok thanks, but i can’t get the method to work…
[code] var instNogietsForm = dhxAccord.cells(“inst_Event_color”).attachForm();
instNogietsForm.loadStruct("inc/xml/forms/inst_agenda_eventcolor_struct.php",function() {
var inputObj = instNogietsForm.doWithItem("colorPicker", "getInput");
myCP = new dhtmlXColorPickerInput(inputObj);
myCP.setImagePath("codebase/imgs/");
myCP.init();
} );[/code]
and before that:
dhtmlXForm.prototype.items.select.getInput=function(item){
return item.childNodes[1].childNodes[0];
};
i’ve included the colorpicker.js and colorpicker.css. Also the dhtmlxform_item_colorpicker.js
What am I doing wrong here ?
Avanox
March 30, 2011, 8:07am
#4
here is a sample of my code. I think i’m using the method for getting the input in the wrong way…
colorpicker.zip (148 KB)
Sorry! That was my mistake. There should be
dhtmlXForm.prototype.items.input .getInput=function(item){
return item.childNodes[1].childNodes[0];
};
instead of
dhtmlXForm.prototype.items.select .getInput=function(item){
return item.childNodes[1].childNodes[0];
};