页面上有一个X-Editable(自动完成)输入。当我激活它并按键盘上的ArrowDown或ArrowUp来选择一个人时,会出现第一个人,但也会出现提示“从列表中选择”并且控制台中出现错误:http://joxi.ru/DmBlqXXsNjNpwA
info.js:
updateRefField(data, fieldName, dictionaryName, projectType) {
if (data !== null && !Number.isInteger(data*1)) {
return this.$q.resolve('Choose from list');
}
return this.ProjectService.updateRefField(data, fieldName, dictionaryName, projectType || this.projectType)
.then((res) => {
if ((data === null) && ((fieldName === 'GorManager') || (fieldName === 'Manager')
|| (fieldName === 'Author') || (fieldName === 'ChiefDesigner') || (fieldName === 'ChiefDesignerAssistant'))) {
var that = this;
setTimeout(function() {
that.$scope.$apply(function() {
that.current[fieldName] = null;
});
}, 4);
}
return this.$q.resolve(res.message || null);
});
}
xeditable-autocomplete.js:
onshow: function () {
var that = this;
setTimeout(function () {
$(that.editorEl.find('select').getKendoComboBox().input).focus();
var oldValue = that.scope.$data;
that.editorEl.find('select').getKendoComboBox().bind('change', function (e) {
if (this.element.val()) {
that.scope.$data = this.dataItem() ? this.dataItem().Id : oldValue;
} else {
that.scope.$data = null;
}
});
that.editorEl.find('select').getKendoComboBox().bind('open', function (e) {
$('.k-popup').on('click', function (event) {
event.stopPropagation();
});
});
that.editorEl.find('select').getKendoComboBox().bind('filtering', function (e) {
var filter = e.filter;
if (!filter.value) {
e.preventDefault();
}
});
}, 4);
}
更新:已解决。在评论中添加了决定。
答案 0 :(得分:2)
问题是,$digest
已在进行中。
尝试更改that.$scope.$apply(function() {
中的that.$scope.$applyAsync(function() {
。
答案 1 :(得分:0)
将选项返回到select中的代码是这样的:
read: (options) => {
EmployeesService.getEmployees(options.data, currentEmployeeId).then((employees) => {
options.success(employees);
});
}
我添加了setTimeout,代码更改为:
read: (options) => {
EmployeesService.getEmployees(options.data, currentEmployeeId).then((employees) => {
setTimeout(function() {
return options.success(employees);
}, 4);
});
}