2016-02-16 2 views
0

На странице есть вход X-Editable (автозаполнение). Когда я активировать его и нажмите ли СТРЕЛКА ВНИЗ или ArrowUp на клавиатуре, чтобы выбрать человека, появляется первый человек, но намек на «Выбрать из списка» выглядит хорошо, и есть ошибка в консоли: http://joxi.ru/DmBlqXXsNjNpwA

Информация .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); 
    } 

UPDATE: решаемые. Добавлено решение в комментарии.

+0

Я прочитал некоторые должности (https: //docs.angularjs.org/error/$rootScope/inprog, http://stackoverflow.com/questions/23128220/angularjs-scope-apply-gives-this-error-error-rootscopeinprog, http: //www.codingeek .com/angularjs/angular-js-apply-timeout-digest-evalasync /, http://www.codelord.net/2015/10/14/angular-nitpicking-differences-between-timeout-and-settimeout/, http://www.ngroutes.com/questions/1a02555/scope-function-is-not-defined-anonymous-function.html), но по-прежнему не может избавиться от ошибки. – rinatoptimus

+0

нет понятия '$ scope' и' $ rootScope' в angular2, я думаю, вы используете angular-1.X –

+0

Я предполагаю, что это ngUpgrade, но я не знаю об этом сам. –

ответ

0

код, который возвращался в опции выбора, как это было:

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

Проблема в том, что $digest уже выполняется.

Попробуйте изменить that.$scope.$apply(function() { на that.$scope.$applyAsync(function() {.

+0

Спасибо, но не работает. Тот же результат. – rinatoptimus

Смежные вопросы