From d7dc48b3a8c7ed74c61c24fa7c5225ff7607d9b2 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 31 Jan 2019 14:24:07 +0100 Subject: [PATCH] Misunderstood how 'this' can change in JS --- Site/Pages/v5/Financial/ValidateReceipts.aspx | 3 ++- Site/Scripts/Swarmops-v5.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Site/Pages/v5/Financial/ValidateReceipts.aspx b/Site/Pages/v5/Financial/ValidateReceipts.aspx index 7e540d2d..e49ee6c5 100644 --- a/Site/Pages/v5/Financial/ValidateReceipts.aspx +++ b/Site/Pages/v5/Financial/ValidateReceipts.aspx @@ -51,7 +51,6 @@ $(".LocalIconUndo").attr('src', '/Images/Icons/iconshock-balloon-undo-128x96px.png').hide(); $(".LocalIconWait").attr('src', '/Images/Abstract/ajaxloader-48x36px.gif').hide(); - $(".LocalIconApproval").click(function () { var itemId = $(this).attr("baseid"); $(this).hide(); @@ -61,6 +60,7 @@ SwarmopsJS.proxiedAjaxCall( "/Pages/v5/Financial/ValidateReceipts.aspx/Validate", { identifier: itemId }, + this, function (result) { if (result.Success) { var itemId = $(this).attr("baseid"); @@ -91,6 +91,7 @@ SwarmopsJS.proxiedAjaxCall( "/Pages/v5/Financial/ValidateReceipts.aspx/RetractValidation", { identifier: $(this).attr("baseid") }, + this, function(result) { if (result.Success) { var itemId = $(this).attr("baseid"); diff --git a/Site/Scripts/Swarmops-v5.js b/Site/Scripts/Swarmops-v5.js index c23680f3..ca7efc0f 100644 --- a/Site/Scripts/Swarmops-v5.js +++ b/Site/Scripts/Swarmops-v5.js @@ -450,12 +450,12 @@ var SwarmopsJS = (function () { // Preserves the "this" object into success and error functions publicSymbols.proxiedAjaxCall = proxiedAjaxCall; - function proxiedAjaxCall(url, params, successFunction, errorFunction) { + function proxiedAjaxCall(url, params, thisObject, successFunction, errorFunction) { ajaxCall( url, params, - $.proxy(successFunction, this), - errorFunction !== undefined? $.proxy(errorFunction, this) : undefined + $.proxy(successFunction, thisObject), + errorFunction !== undefined? $.proxy(errorFunction, thisObject) : undefined ); }