From 4f8087d62b646f99e42d2d745ea9c39fdbfe0bfb Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Sun, 11 Dec 2016 21:18:40 -0600 Subject: [PATCH] refactor _this usage into proper function binding --- app/assets/javascripts/preview_markdown.js | 26 +++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/preview_markdown.js b/app/assets/javascripts/preview_markdown.js index 2526cd391f0..e2260b37f91 100644 --- a/app/assets/javascripts/preview_markdown.js +++ b/app/assets/javascripts/preview_markdown.js @@ -25,13 +25,11 @@ this.hideReferencedUsers(form); } else { preview.text('Loading...'); - this.renderMarkdown(mdText, (function(_this) { - return function(response) { - preview.html(response.body); - preview.renderGFM(); - _this.renderReferencedUsers(response.references.users, form); - }; - })(this)); + this.renderMarkdown(mdText, (function(response) { + preview.html(response.body); + preview.renderGFM(); + this.renderReferencedUsers(response.references.users, form); + }).bind(this)); } }; @@ -50,15 +48,13 @@ text: text }, dataType: 'json', - success: (function(_this) { - return function(response) { - _this.ajaxCache = { - text: text, - response: response - }; - success(response); + success: (function(response) { + this.ajaxCache = { + text: text, + response: response }; - })(this) + success(response); + }).bind(this) }); };