【发布时间】:2015-05-28 12:00:21
【问题描述】:
在best practice guide 之后,我收到一个错误“Uncaught TypeError: undefined is not a function”。
通过大量的console.logs,我发现在以下代码行中抛出了这个错误(在控制台中匿名):
oView.getElementBinding().attachEventOnce(....)
AttachEventOnce() 是导致问题的函数。你知道如何解决这个问题或进一步调试吗?
代码块:
oView.getElementBinding().attachEventOnce("dataReceived", jQuery.proxy(function () {
var oData = oView.getModel().getData(sReportPath);
if (!oData) {
sap.ui.core.UIComponent.getRouterFor(this).myNavToWithoutHash({
currentView : oView,
targetViewName : "namespace.view.NotFound",
targetViewType : "XML"
});
}
}, this));
引自最佳实践指南:
// Check that the product specified actually was found oView.getElementBinding().attachEventOnce("dataReceived", jQuery.proxy(function() { var oData = oView.getModel().getData(sProductPath); if (!oData) { sap.ui.core.UIComponent.getRouterFor(this).myNavToWithoutHash({ currentView : oView, targetViewName : "sap.ui.demo.tdg.view.NotFound", targetViewType : "XML" }); } }, this));
这整个事情是在“routeMatched”部分触发的。
【问题讨论】:
-
之前发生了什么?在最佳实践指南中,此调用之前有一些内容。您是否尝试过 Chrome 的异常停止功能?
-
@matbtt 我想我找到了错误。这是 OData 后端的问题。我没有实现“readEntity”……啊,没关系,检查我的答案;P
标签: javascript model-view-controller url-routing sapui5