r/coffeescript • u/crmpicco • Jan 08 '16
Scoping issue when attempting to call CoffeeScript method inside Fancybox callback
I have the following CoffeeScript module named Course. I have a small piece of code which I would like to re-use, I have created a method called preSelectItemSize.
I would like to call this method when init is called and also within the afterShow Fancybox callback. The following code works, but it don't believe it is correct to use the module name and I should be using the @ reference to "this" instead.
What am I doing wrong? (Code snippet reduced for brevity)
3
Upvotes
View all comments
Show parent comment
1
u/mc_hammerd Jan 12 '16
did you fix it? i think if you change the
->to a fat arrow for the init function it should work.