I am writing a Pebble app in Pebble.js which needs to run different functions when the same button is pressed at different times throughout the app.
I can easily associate a function with a button:
dispWindow.on('click', 'up', function(e) {
doSomething();
});
After doSomething runs a few times, I need to change what happens when the user clicks the "up" button in the dispWindow Window. I can add this code:
dispWindow.on('click', 'up', function(e) {
doSomethingElse();
});
However, when the user clicks the "up" button, doSomething and doSomethingElse both fire. How do I remove doSomething from the "up" button?
You can use the off event, like this:
dispWindow.off('click');
Then, call the on event again after that:
dispWindow.on('click', 'up', function(e) {
doSomethingElse();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With