在coffeescript中,我想从jquery回调中调用一个类方法,如何访问类的范围? this.loadImage(当前索引)不起作用
class ImageCarousel
currentIndex = 0
jsonPath = "json/images.json"
images = null
constructor: () ->
this.loadJson()
loadJson: () ->
$.ajax jsonPath,
success : (data, status, xhr) ->
console.log("yea "+data)
this.images = data.images
this.loadImage(currentIndex)
error : (xhr, status, err) ->
console.log("nah "+err)
complete : (xhr, status) ->
console.log("comp")
loadImage:(@index) ->
console.log("load image "+@index)