class MyClass
defaultOptions:
url: '/photos.json'
constructor: (@element, @options) ->
@photos = []
@init()
addPhotos: (photo) ->
@photos.push photo
request: ->
$.getJSON(this.defaultOptions.url).done((data) ->
@addPhotos data
return
).fail (jqxhr, textStatus, error) ->
err = textStatus + ', ' + error
console.log 'Request Failed: ' + err
return
init: ->
@request()
When I run this command from the console
var myClass = new MyClass("#myElement")
I get this error
TypeError: this.addPhotos is not a function. (In 'this.addPhotos(data)', 'this.addPhotos' is undefined)
Any idea why Im not being able to call addPhotos method inside the request method and how could I call it?