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

✨ new(select): select smartsearch custom url option added. #553

Open
wants to merge 1 commit into
base: version/2.12.23
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions assets/js/shared-ui/select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,27 @@

};

SUI.select.formatSearchOptions = ( data, container ) => {

let markup;

const label = SUI.select.escapeJS( data.text );
const url = $( data.element ).attr( 'data-url' );

if ( ! data.id ) {
return label; // optgroup.
}

if ( 'undefined' !== typeof url ) {
markup = '<span class="sui-search-name">' + label + '</span><span class="sui-search-url">' + url + '</span> ';
} else {
markup = label;
}

return markup;

};

SUI.select.formatVarsSelection = ( data, container ) => {

let markup;
Expand Down Expand Up @@ -235,6 +256,10 @@
dropdownParent: selectParent,
minimumInputLength: 2,
maximumSelectionLength: 1,
templateResult: SUI.select.formatSearchOptions,
escapeMarkup: function( markup ) {
return markup;
},
dropdownCssClass: isSmall
});
};
Expand Down