Problem: A function I am binding with a click event is firing off on bind.
I've found others with this same problem and found a couple of answers. However, on implementing those solutions, I am still seeing the same issue. I must be doing something wrong, but I can't seem to figure it out.
Demo of issue: https://jsfiddle.net/b35krwfh/16/
Original snippet of code (coffeescript) that was calling the function on bind:
$("body").bind "click", deviceCloseView
After some online research, I found the below as the recommended fix, but I'm still experiencing the same issue:
$("body").bind "click", ->
deviceCloseView()
Update: it was suggested I remove the parenthesis, but that doesn't seem to fix the issue as it isn't executing at all when I do that:
$("body").bind "click", ->
deviceCloseView
https://jsfiddle.net/b35krwfh/15/
Some references I used trying to fix this:
jQuery function called in a .bind click handler is running on document ready
Why does click event handler fire immediately upon page load?