Merge pull request #22229 from colemanw/searchKitExport
[civicrm-core.git] / ang / crmUi.js
index 7daef656ccededda09ed128a954d697ef2360159..944630d4dbf8eb7a6c6b11b4b9508734243671ec 100644 (file)
     // 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: <select crm-ui-select='{...}' on-crm-ui-select="alert("User picked this item: " + selection)"></select>
-    .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});
+            });
           });
         }
       };
           else {
             $(element).prepend('<span class="icon ui-icon-' + attrs.crmIcon + '"></span> ');
           }
-          if ($(element).is('button')) {
+          // Add crm-* class to non-bootstrap buttons
+          if ($(element).is('button:not(.btn)')) {
             $(element).addClass('crm-button');
           }
         }