diff --git a/ang/crmUi.js b/ang/crmUi.js index 20ee8b1a8f10..7daef656cced 100644 --- a/ang/crmUi.js +++ b/ang/crmUi.js @@ -633,6 +633,22 @@ }; }) + // 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) { + 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}); + }); + } + }; + }) + // Render a crmEntityRef widget // usage: .directive('crmEntityref', function ($parse, $timeout) {