XF 2.1 Changing color picker text in JS?

Jaxel

Well-known member
I have a color picker on my form:
Code:
<div class="inputGroup inputGroup--joined inputGroup--color" data-xf-init="color-picker">
    <span class="inputGroup-text">{$field.field_key}_{$i}</span>
    <xf:textbox class="colors c{$i} {$field.field_key}_{$i}" name="fields[{$field.field_key}_{$i}]"
        value="rgb(0,0,0)" />

    <span class="inputGroup-text"><span class="colorPickerBox js-colorPickerTrigger"></span></span>
    <span class="inputGroup-text inputGroup-text--rgbTxt"><span class="js-rgbTxt-r"></span></span>
    <span class="inputGroup-text inputGroup-text--rgbTxt"><span class="js-rgbTxt-g"></span></span>
    <span class="inputGroup-text inputGroup-text--rgbTxt"><span class="js-rgbTxt-b"></span></span>
</div>

It works great.

However, I am using some javascript to change the contents of the textbox progmatically. This also works great. But, when I change the contents of the text box, the contents of the color picker box and the rgb text do not get updated to match the the text box.

How can i get this to fire off on update to the text box?
 
I figured it out... I can manually trigger the paste event:

Code:
$input.trigger('paste');
 
Back
Top Bottom