CRM-20871 - crmUiSelect - UI should stay in sync with model
authorTim Otten <totten@civicrm.org>
Fri, 14 Jul 2017 02:46:58 +0000 (19:46 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 14 Jul 2017 02:46:58 +0000 (19:46 -0700)
The `crmUiSelect` defines the function `$render()` -- whenever the model
changes, it should update execute `$render()` to update the UI.  But it doesn't.

This issue is discussed more in https://stackoverflow.com/questions/21084088/why-ngmodels-render-is-not-called-when-the-model-changes-in-angularjs

== Before ==

The `$render()` function for directive `crm-ui-select` is not called because the `select`
directive overrides it.

== After ==

The `$render()` function for directive `crm-ui-select` is called, even if
used on a `select` element.

== Acceptance Criteria ==

 * The test page in https://github.com/totten/org.example.angpage (`civicrm/a/#/play`)
   keeps elements synchronized.
 * Existing screens which use `crm-ui-select` continue to work.

ang/crmUi.js

index 4ea687c32964e87a5d0dad35ac30c3bcb92e454f..d3ea3a469c6f3f2efdb7c9e1bc31928089e01234 100644 (file)
     .directive('crmUiSelect', function ($parse, $timeout) {
       return {
         require: '?ngModel',
+        priority: 1,
         scope: {
           crmUiSelect: '='
         },
             element.crmSelect2(scope.crmUiSelect || {});
             if (ngModel) {
               element.on('change', refreshModel);
-              $timeout(ngModel.$render);
             }
           }