Apologies for the vague title, it's kind of hard to explain in a line...
In any case, let's say I have a button with an action as defined by the data-action
property. When the user clicks said button, something happens, and the button's action will change to its second state.
However, implementing this, I am finding that the event that is defined for that second state gets run automatically after the first state is triggered, as though the "click" persists past the function call and triggers the second event.
One click should show the log 'transitioning to "foo"', and a second click should show the log 'transitioning to "bar"', but if you try it out, you'll see that both events are fired.
How can I stop this?
Edit: Thanks Dimitar for the help -
var action = ((this.retrieve('action', 'foo') != this.getProperty('data-action')) ? 'bar' : 'foo' );
if (action == 'foo') {
console.log('executing "foo"');
this.store('action', 'bar');
}
else {
console.log('executing "bar"');
this.store('action', 'foo');
}