knucklemonk (2) [Avatar] Offline
#1
Hi,

I have been implementing the SPA architecture in a relatively modest web app and one of the functions in one of the modules remains undefined and unreachable for reasons I cannot fathom (the name of the variable which holds a reference to the function is estimateNewBodyFat). It is declared at the top of the the closure function along with 2 other functions initModule and estimateRacingWeight, the former of which is returned as the public initialization function, the other is bound to a form's submit event using JQuery's on() method. estimateRacingWeight calls estimateNewBodyFat during its calculations. I verified that everything works as a stand-alone app with no closures, but since plugging these functions into an encapsulating closure function, estimateNewBodyFat always comes up undefined. The only obvious difference between the 3 functions is that estimateNewBodyFat takes several arguments. I've compared the code structurally to the examples in the book and everything seems set up the same way. Help!

Thanks,
Josh S.
knucklemonk (2) [Avatar] Offline
#2
Re: Trouble with a function in a closure
Funny how this works... I no sooner posted this then went back to the code and the bug popped out like a sore thumb.
seasoup (37) [Avatar] Offline
#3
Re: Trouble with a function in a closure
Glad we could help, let me know if you need anything else.