From 63c627264589c5a82f2b15d10a8a774e4a0679e8 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 16 Jul 2021 15:11:36 -0400 Subject: [PATCH] Fix onCrmUiSelect to use current scope and apply to the digest cycle Evaluates expression in current scope rather than parent scope, and uses $scope.$apply. --- ang/crmUi.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ang/crmUi.js b/ang/crmUi.js index 7daef656cc..16ef03f0ba 100644 --- a/ang/crmUi.js +++ b/ang/crmUi.js @@ -636,14 +636,16 @@ // Use a select2 widget as a pick-list. Instead of updating ngModel, the select2 widget will fire an event. // This similar to ngModel+ngChange, except that value is never stored in a model. It is only fired in the event. // usage: - .directive('onCrmUiSelect', function ($parse) { + .directive('onCrmUiSelect', function () { return { priority: 10, link: function (scope, element, attrs) { element.on('select2-selecting', function(e) { e.preventDefault(); element.select2('close').select2('val', ''); - scope.$parent.$eval(attrs.onCrmUiSelect, {selection: e.val}); + scope.$apply(function() { + scope.$eval(attrs.onCrmUiSelect, {selection: e.val}); + }); }); } }; -- 2.25.1