Skip to content

Commit

Permalink
Merge pull request #31859 from colemanw/iconPickerFix
Browse files Browse the repository at this point in the history
Improve crmUiIconPicker with ngModel support for binding
  • Loading branch information
mattwire authored Jan 27, 2025
2 parents 1c9cc60 + f0e40a5 commit 24b66b4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ang/crmUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -1294,10 +1294,21 @@
.directive('crmUiIconPicker', function($timeout) {
return {
restrict: 'A',
controller: function($element) {
require: '?ngModel', // Soft require ngModel
controller: function($element, $scope, $attrs) {
CRM.loadScript(CRM.config.resourceBase + 'js/jquery/jquery.crmIconPicker.js').then(function() {
$timeout(function() {
$element.crmIconPicker();

// If ngModel is present, set up two-way binding
if ($attrs.ngModel) {
$scope.$watch($attrs.ngModel, function(newValue) {
if (newValue !== undefined) {
// Update the value in the picker
$element.val(newValue).trigger('change');
}
});
}
});
});
}
Expand Down

0 comments on commit 24b66b4

Please sign in to comment.