I wrote some js:
var folersTreeMgr = {
sendDeleteFolderRequestAndUpdateFoldersTree: function () {
...
} else {
createAjaxRequest("Manager/DeleteLocation", {
'locationId': folder_minimal_descriptor.locationId
}).done(function (isSucceeded) {
if (isSucceeded) {
folersTreeMgr.deleteFolderInFoldersTree(); // works
this.deleteFolderInFoldersTree(); // doesn't work
deleteFolderInFoldersTree(); // doesn't work
}
//TODO: else: error
});
}
},
deleteFolderInFoldersTree: function () {
$("#jstree").jstree("remove", null);
}
};
why do I get “missing function” error
Because you’re using
thisinside a callback, where it has different meaning.You can referene the outer
thisin a variable, then use that in the callback.Or use
$.proxyto keep thethisvalue…This’ll return a function that has the second argument to
$.proxybound to the function passed as the first argument.