0

How to write this jQuery code

$(selector).on('click.custom-namespace', function () {...});

into vanilla JavaScript solution? addEventListener don't get events with custom namespace.

Thanks

6
  • Possible duplicate of Event Handler Namespace in Vanilla JavaScript Commented Aug 8, 2017 at 16:38
  • Possible duplicate of JavaScript click event listener on class Commented Aug 8, 2017 at 16:38
  • This takes some additional setup in vanilla JS to do. There are small libraries that help with this sort of thing: For example: event-bundle Commented Aug 8, 2017 at 16:40
  • Trigger/fire of custom event might also help you stackoverflow.com/questions/7057223/… Commented Aug 8, 2017 at 16:46
  • @Hitmands thanks, I have already read this thread and I also try custom Event class that Andrew mention. But this has one problem and it is if I declare same event name with same namespace to two or more different elements. Other answer was irrelevant. Commented Aug 8, 2017 at 17:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.