无法在idata后期调用中调用控制器方法

时间:2019-11-01 06:04:42

标签: javascript sapui5

我无法在oData发布成功调用内调用任何自定义函数。

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);
  }

1 个答案:

答案 0 :(得分:0)

您的那个变量是本地变量,因此您无法通过onSubmit函数访问它。您可以在 oModel.create 行之前将 this 分配给那个