Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using jscolor.js on dynamic input

Tags:

jscolor

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

i'm trying to attach it to some dynamic inputs, but to no avail. dynamic inputs in terms of, on page load the input doesn't exist, only after the user click on something the input will become available. for example, I have a rows of data, and each row has different background color. this row of data are loaded using ajax. at the end of each row, there's an edit button. by clicking the edit button, it will display an input text box for the clicked row. I want to call the jscolor picker when the user clicks on the input text box. how can I do this?

thanks

like image 537
imin Avatar asked Oct 30 '13 20:10

imin


2 Answers

Got the same problem upon adding input fields dynamically

Managed to make it work by calling jscolor.install();

PS: jscolor v2.4.5

like image 117
Michael Yohanes Avatar answered Sep 20 '22 14:09

Michael Yohanes


I just had this problem too but luckily it's easy to fix. You need to (re)init jscolor after you have dynamically created your inputs:

jscolor.init()
like image 39
BStone Avatar answered Sep 21 '22 14:09

BStone