Misunderstood how 'this' can change in JS
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user