No, in my scenario I’m referring to the same button. I have a button within a repeater that I’m configuring its onClick listener in the $('#repeater').forEachItem, when I’m refreshing the dataset that the repeater is linked with the forEachItem is reinvoked. Anyways my question was whether is there a way to remove an onclick listener that was previously added.
If you work with REPEATER (inside repeater (intern scope) you will have to use…
$item()
…insted of …
Sw()
… do you recognize the difference???
To remove the onClick-Listener itself is not possible, but you can generate a counter, which will count the clicks. Setting the counter to → 2 and if counter ===2 nothing happens anymore, if counter under 2 click-action.
Hi, there’s a removeEventListener equivalent:
Something like:
function handleClick1(){
console.log('Does Something')
}
function handleClick2(){
console.log('Does Another Thing')
}
$w.onReady(() => {
$w('#myButton').onClick(handleClick1);
//when you want to remove the click event handler:
$w('#myButton').remvoeEventHandler('click', handleClick1);
//when you want to apply a new handler:
$w('#myButton').onClick(handleClick2);
})
By the way, removing the event handler will not change the cursor style back from pointer to auto.
I hope Wix will let us set the cursor style in the future.
Yes. I think it’s currently not documented. But I asked the Wix Team if we could rely on it and they said we could use it and they were going to document it.