In Wix I think we can’t update or overwrite our eventlisteners like onClick what can I do about this issue?
Example:
$w("#Button123").onClick((event) => { runFunction() })
$w("#Button123").onClick((event) => { runFunction() })
If I write this code runFunction will be fired 2x times. This is the issue that I’m having. Also even if I have different functions like:
$w("#Button123").onClick((event) => { runFunction() })
$w("#Button123").onClick((event) => { runFunctionTwo() })
Again both will fired. Another example:
function setup() {
$w("#Button123").onClick((event) => {
console.log(123)
})
}
setup()
function updateItems() {
setup()
}
updateItems()
In this exmaple I would see 2x console.log(123) even if I click once. Because updateItems function created the same eventlistener once again!
This is the issue I hope I was able to let you understand what I meant. So?
How can I overwrite or basically update my eventlistener and not create new one each time?
Wix must make an update about this and let eventlisteners overwrite automatically. How it should be example:
$w("#Button123").onClick((event) => { runFunction() })
$w("#Button123").onClick((event) => { runFunctionTwo() })
Only runFunctionTwo will be executed. Each time we create new eventListener it should overwrite old one.
-Maybe Wix can create a new selector like $o and we can use it when we want to overwrite.
(I’m not a master so maybe I’m thinking false but this is my idea because I’m having problem with this)