我有另一个从服务器调用“GetEmployee”函数的函数,当我在 Chrome 调试器中检查调用时,我可以看到我的详细信息按预期通过,所以这不是服务器端错误。
但是,如果我在断点的第三行放置断点,quickBookingSource
则永远不会到达。我确实有quickBooking:quickBookingSource
viewModel 定义,并且没有拼写错误。
此外,您会看到我添加了一个带有“blah”文本的三元运算符作为安全网,但无济于事
我收到的错误消息是:
Uncaught ReferenceError: Unable to process binding "text: function (){return project }"
Message: project is not defined
代码是:
HTML
<div data-bind="dxTileView: {listHeight:tileWidgetHeight,itemClickAction:sendProject,baseItemHeight: 80, baseItemWidth: 100,dataSource:quickBooking}">
<div data-options="dxTemplate : { name:'item' }" class="tile">
<h2 data-bind="text: project"></h2>
<p data-bind="text: name"></p>
<p data-bind="text: costCenter"></p>
<p>Jetzt Büchen</p>
</div>
</div>
JS
var quickBookingSource = DevExpress.data.createDataSource({
load: function (loadOptions) {
if (loadOptions.refresh) {
var deferred = new $.Deferred();
callService("GetEmployee",
{
employeeNo: aktivEmployee.id
},
function (result) {
var mapped = $.map(result, function (data) {
return {
name: data.LastNProjects? data.LastNProjects["Name"]:"blah",
project: data.LastNProjects? data.LastNProjects["Address"]:"blah",
costCenter: data.LastNCostCenters? data.LastNCostCenters["Name"]:"blah"
}
});
deferred.resolve(mapped);
});
return deferred.promise();
}
},
});
提前致谢