coffeescript-cookbook / coffeescript-cookbook.github.io

CoffeeScript Recipes, Examples and Tutorials
https://coffeescript-cookbook.github.io
Other
562 stars 178 forks source link

Callback bindings #124

Closed jonathan-s closed 9 years ago

jonathan-s commented 9 years ago

Looking at the following code. According to the recipe on Callback bindings next should be executed. However it is not.

class MyClass:    
   constructor: () =>
       @showCarouselInfo()
       @next() 

   next: () =>
        console.log 'fires'

    showCarouselInfo: =>
      getIndex = (string) =>
        number = parseInt(string.match(/\d+/))

      $('.ball').on 'click', (e) =>
        console.log('fire')
        index = getIndex(e.currentTarget.id)
        info = $('.carousel-wrapper > p')
        @next(info[index])
sukima commented 9 years ago

Check your indentations, Looks like coffescript could be compiling it wrong if that's the actual code and not a copy/paste mishap on the white spacing.