joeattardi / picmo

JavaScript emoji picker. Any app, any framework.
https://picmojs.com
MIT License
1.19k stars 118 forks source link

picker.on is not a function #255

Closed jakenoble closed 1 year ago

jakenoble commented 1 year ago

How do you use the on event? I always get picker.on is not a function, the picker shows so it has worked up until the event.

<script type="module">
  import { createPicker } from "https://unpkg.com/picmo@latest/dist/index.js?module";
  const container = document.querySelector('.pickerContainer');
  const picker = createPicker({
    rootElement: container
  });
  picker.on('emoji:select', selection => {
    console.log('Selected emoji: ', selection.emoji);
  });
</script>
jakenoble commented 1 year ago

.on is now .addEventListener

But it is not documented.

joeattardi commented 1 year ago

Which documentation were you looking at? addEventListener is documented in the README as well as the API on picmojs.com

jakenoble commented 1 year ago

https://picmojs.com/docs/usage/emoji-selection


const picker = createPicker();

picker.on('emoji:select', selection => {
  console.log('Selected emoji: ', selection.emoji);
});```
joeattardi commented 1 year ago

Aha, thanks! Looks like I missed a spot. I’lol make sure it’s up to date, thanks!

joeattardi commented 1 year ago

Updated: https://picmojs.com/docs/usage/emoji-selection/

const picker = createPicker();

picker.addEventListener('emoji:select', selection => {
  console.log('Selected emoji: ', selection.emoji);
});