问题
For example, when using select2 muti-value, user entered 'new', and it showed
- New Mexcio
- New Hampshire
- New Jersey
- New York
After selecting 'New Mexcio', and the user would like to select again from the rest of the 3 remaining. In order to to do that, the user has to enter 'new' again.
Is there a way to retain the results instead of clear out the 'query?
Thanks
回答1:
Sounds like you want to persist a query from one search to the next. You might want to check out the nextSearchTerm
property.
To display the current value in the next search,
function displayCurrentValue(selectedObject, currentSearchTerm) {
return currentSearchTerm;
}
$("#e1").select2({
nextSearchTerm: displayCurrentValue
});
来源:https://stackoverflow.com/questions/23985492/how-to-retain-select2-results-after-select