Search Results

Search found 1 results on 1 pages for 'pandabrand'.

Page 1/1 | 1 

  • Coffeescript getting proper scope from callback method

    - by pandabrand
    I've searched for this and can't seem to find an successful answer, I'm using a jQuerey ajax call and I can't get the response out to the callback. Here's my coffeescript code: initialize: (@blog, @posts) -> _url = @blog.url _simpleName = _url.substr 7, _url.length _avatarURL = exports.tumblrURL + _simpleName + 'avatar/128' $.ajax url: _avatarURL dataType: "jsonp" jsonp: "jsonp" (data, status) => handleData(data) handleData: (data) => console.log data @avatar = data Here's the compiled JS: Blog.prototype.initialize = function(blog, posts) { var _avatarURL, _simpleName, _url, _this = this; this.blog = blog; this.posts = posts; _url = this.blog.url; _simpleName = _url.substr(7, _url.length); _avatarURL = exports.tumblrURL + _simpleName + 'avatar/128'; return $.ajax({ url: _avatarURL, dataType: "jsonp", jsonp: "jsonp" }, function(data, status) { return handleData(data); }); }; Blog.prototype.handleData = function(data) { console.log(data); return this.avatar = data; }; I've tried a dozen variations and I can't figure out how to write this? Thanks.

    Read the article

1