I have a callback without parameters and it stored in an object with no execution like so:
{callback:function(){ do my thing }}
Then I realized I needed to send in some parameters, and all the sudden JS is executing the function upon discovery:
{callback:(function(e){ do my thing with e })(event)}
Is there a way to do this without it executing immediately?
The problem is in your second snippet you are invoking the function with (event).
You should just be able to remove it and when the callback is executed, if an event is passed to the callback it will be e:
{callback:function(e){ do my thing with e }}
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