Reputation: 22456
I have what looks like to me to be a simple variable assignment not working.
This code is in jQuery, for the context see here.
I'm calling:
$('#foo').on('someEvent', eventHandlerFn);
And I get this issue within the jQuery on
function. Here's the starting point:
As you can see from the console below the code, selector
is set the my eventHandlerFn
and the fn
variable is undefined. This is as expected.
On line 3509, the value of selector
is assinged to fn
. So, the value of fn
should be same as the value of selector
, no??
See below - selector
is defined, as expected, but fn
is still undefined. Why?
The end result is that my event handler is never registered.
Upvotes: 2
Views: 758
Reputation: 22456
This seems to be an issue with the debugger in Chrome - either a material problem or just a nuance of the debugger that I don't understand. fn does have a value toward the end of the call, but not where the breakpoint is.
Upvotes: 1
Reputation: 195992
The code runs well as shown in the following two screens (the issue is on how chrome sets the context to the console)
It looks like console has access to the variable at definition time (in this case the passed parameters) and not the live values as you run the code
Before the swap
After the swap
Upvotes: 2