Unbind data-actions


#1

What’s currently the best way to unbind a data-action event?


#2

I have no idea if it is a good practice or not but here is a pattern that I have used recently.

Rather than updating the html to remove the specific string in the data-action attribute, I define in my controller a preventThisAction boolean state variable.
Then before doing anything in my action I check this value and return immediately if the action is disabled.

Here is a little example (inspired by a previous example of @javan :wink: )
https://jsfiddle.net/adrienpoly/gLz7pfu5/4/

I have not tested to remove the action from the Html, I suppose it would work, it is just too painful to manage (IMHO) when you have several actions.