jmadler / emoji-picker

Add a slick emoji selector to input fields and textareas on your website.
Other
1.32k stars 318 forks source link

Doesn't work in multiple places #131

Closed yawerhussain42 closed 4 years ago

yawerhussain42 commented 5 years ago

I have two text areas in a single page where i want to use these emojis but it doesn't show up to the second place.

fleduc commented 5 years ago

Did you find a solution to this problem? I also have the same.

It seems that "setupButton" on line 237 is not fired on dynamically added forms, then the "On Click" event is not registered for this new "emoji-picker"

fleduc commented 5 years ago

Ok, when you dynamically create an input field, to be used for emoji use this workflow:

  1. Add your field (using JQuery of pure JS)
  2. Add the emoji attribute (using pure JS, it won't work if you use JQuery)
  3. Execute discover function

Like this:

form.append('<input type="text" id="' + 'chatInput-' + uid +'"/>'); document.getElementById('chatInput-' + uid).setAttribute('data-emojiable', true); window.emojiPicker.discover();

When you use JQuery to set attributes, discover function won't find your input field

Hope it helps