无法在 OData post 调用中调用控制器方法
Not able to invoke controller method inside OData post call
我无法在 oData post 成功调用中调用任何自定义函数。
onSubmit: function () {
var that = this; that.onInit();
}
oModel.create("/Entity", postData, {
success: function (oRetrievedResult) {
var that=this;
lv_BusyDialog.close();
var msg = 'Success!';
MessageToast.show(msg);
that.onSubmit();
// This onSubmit is getting not called here.
},
error: function (oError) {
/* do something */
lv_BusyDialog.close();
var msg1 = 'error';
MessageToast.show(msg1);
}
您的 that 变量是本地变量,因此您无法通过 onSubmit 函数访问它。您可以在 oModel.create 行之前将 this 分配给 that。
我无法在 oData post 成功调用中调用任何自定义函数。
onSubmit: function () {
var that = this; that.onInit();
}
oModel.create("/Entity", postData, {
success: function (oRetrievedResult) {
var that=this;
lv_BusyDialog.close();
var msg = 'Success!';
MessageToast.show(msg);
that.onSubmit();
// This onSubmit is getting not called here.
},
error: function (oError) {
/* do something */
lv_BusyDialog.close();
var msg1 = 'error';
MessageToast.show(msg1);
}
您的 that 变量是本地变量,因此您无法通过 onSubmit 函数访问它。您可以在 oModel.create 行之前将 this 分配给 that。