Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(REF) crmUi - Support onCrmUiSelect for using select2 as a picklist #20789

Merged
merged 1 commit into from
Jul 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ang/crmUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: <select crm-ui-select='{...}' on-crm-ui-select="alert("User picked this item: " + selection)"></select>
.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: <input crm-entityref="{entity: 'Contact', select: {allowClear:true}}" ng-model="myobj.field" />
.directive('crmEntityref', function ($parse, $timeout) {
Expand Down