Question

i'm using famous http://jscolor.com/ color picker script.

The problem appears when I try to link foreign elements (author's example here http://jscolor.com/try.php#linking-foreign-elements ). I want to give a posibillity for user to add another input field by pressing button, so after that, new input field with class="color {valueElement: 'myValue'}" appears but the script ignores it, and just acts as it's regular jscolor input field (without 'linking to foreign elements' option).

    $( "input[id=p1]" ).after('<input class="color {valueElement:\'myValue\'}" id="plus" type="text" name="color[]" required />');
    new jscolor.color(document.getElementById('plus'), {})

any ideas ? Thanks in advance

Était-ce utile?

La solution

You need to bind the new input field you've added. Otherwise your JS can't see the new element because it didn't exist in the DOM when it ran.

In fact the next entry on the link that you gave deals with this.

http://jscolor.com/try.php#manual-binding

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top