diff --git a/ang/crmUi.js b/ang/crmUi.js index 462d547a8dff..0f3019eb0a20 100644 --- a/ang/crmUi.js +++ b/ang/crmUi.js @@ -755,15 +755,12 @@ }; if (ctrl.ngModel) { - var oldValue; // Ensure widget is updated when model changes ctrl.ngModel.$render = function() { - element.val(ctrl.ngModel.$viewValue || ''); // Trigger change so the Select2 renders the current value, // but only if the value has actually changed (to avoid recursion) - if (!angular.equals(ctrl.ngModel.$viewValue, oldValue)) { - oldValue = ctrl.ngModel.$viewValue; - element.change(); + if (!angular.equals(ctrl.ngModel.$viewValue || '', element.val())) { + element.val(ctrl.ngModel.$viewValue || '').change(); } };