在 coffescript 中,我想从 jquery 回调中调用一个类方法,如何访问该类的范围?this.loadImage(currentIndex) 不起作用
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)