I am working with Typescript and have an ajax call that on Success is calling another function \ method.
deleteTheseSuccess(data) {
new Fe.Upsm.Head().showGlobalNotification("Selected Items Deleted");
this.refreshPrintQueueGrid(); <== this is there the error existst
(window as any).parent.refreshOperatorPrintQueueCount();
}
the method call that I have pointed out above is trying to call
refreshPrintQueueGrid() {
$("#PrintQueueGrid").data("kendoGrid").dataSource.read();
this.refreshPrintQueueStats();
}
This compiles without any issues in VS2017 and produces the JavaScript files accordingly
and this is the call in the JavaScript output
PrintQueue.prototype.refreshPrintQueueGrid = function () {
$("#PrintQueueGrid").data("kendoGrid").dataSource.read();
this.refreshPrintQueueStats();
};
The exact error that I get is
Uncaught TypeError: this.refreshPrintQueueGrid is not a function.
I would be grateful if anyone can help me understand what is going wrong here and what would cause this as I will have this in a number of places over my application.
--- Edit compiled code
PrintQueue.prototype.refreshPrintQueueGrid = function () {
$("#PrintQueueGrid").data("kendoGrid").dataSource.read();
this.refreshPrintQueueStats();
}
--- Edit 2 -- Class
namespace Fe.Upsm {
export class PrintQueue {
callingView: string
constructor(callingView: string) {
this.callingView = callingView;
this.documentReadyObjects();
}
refreshPrintQueueGrid() {
$("#PrintQueueGrid").data("kendoGrid").dataSource.read();
this.refreshPrintQueueStats();
}
deleteThese(ids) {
var jsonObj = {
ids: ids
}
var dataAccess = new DataAccess.AjaxDataAccessLayer(Fe.Upsm.Enums.AjaxCallType.Post,
Fe.Upsm.Enums.AjaxDataType.json,
"../../PrintQueue/DeletePrintQueueItems",
jsonObj);
dataAccess.ajaxCall(this.deleteTheseError, this.deleteTheseSuccess);
}
deleteTheseSuccess(data) {
new Fe.Upsm.Head().showGlobalNotification("Selected Items Deleted");
this.refreshPrintQueueGrid;
(window as any).parent.refreshOperatorPrintQueueCount();
}
deleteTheseError(xhr) {
alert("An Error Occurred. Failed to delete print queue items");
}
}
}