Correct way to add multiple event listeners
See original GitHub issueI have the following code and I’m trying to add multiple event handlers to a slider, but I keep getting the following error “namespacedEvent.split is not a function”… What is the correct way of doing this?
noUiSlider.create(testSlider, {
start: 0,
step: 1,
range: {
'min': 0,
'max': 10,
},
format: {
to: function (value) {
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
},
from: function (value) {
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
},
},
}).on(
{
'slide': function (values, handle) {
console.log("Slide Fired");
}
},
{
'end': function (values, handle) {
console.log("End Fired");
}
}
);
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
adding multiple event listeners to one element - Stack Overflow
const element = document.querySelector("#myId"); function handleEvent(e) { // do something } // I prefer string.split because it makes editing the event list ...
Read more >Listening to multiple events in vanilla JS - Go Make Things
In vanilla JavaScript, each event type requires its own event listener. Unfortunately, you can't pass in multiple events to a single listener ...
Read more >How to Add Event Listeners to Multiple Elements using ...
The process is the same, simply query for the element or elements, then add an event listener to each individual element. Hopefully, this...
Read more >Chapter 4. Multiple Event Handlers: Two's company - O'Reilly
We need a way to assign more than one handler to an event, which means we can't just assign a handler to an...
Read more >How to add an event listener to multiple elements in JavaScript
How to add an event listener to multiple elements in JavaScript ; document.querySelector · '.my-element' ; document.querySelectorAll · '.some-class' ; [document.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Call
on
multiple times, like so:This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.