-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
allowClear option with ajax load #1785
Comments
You should be able to use |
KB, you are correct sir. While I did specify a placeholder, it was an empty string. I have changed it to a single whitespace and now it is working. Thanks. |
Can you tell me or paste an example of code to know how did you add placeholder for select2 ajax call @kylemwhite Thanks |
Was this issue related to < 4.* those days @kylemwhite ? Here is an example with 4.0.3 using $j("#customerId").select2({
minimumInputLength: 2,
placeholder: 'All',
allowClear: true,
ajax: {
url: "/customer/autocomplete",
dataType: 'json',
delay: 400,
processResults: function (data) {
return {
results: data
};
}
}
}).val('1').trigger('change'); <select id="customerId" name="customerId" style="width: 300px;">
<option value=""></option>
<option value="1">Pre-selected Customer here</option>
</select> |
I'm not sure if I'm misunderstanding or if my use case is just not possible right now. From what I can tell, it is not possible to have the allowClear icon on an S2 box that uses ajax because ajax requires an INPUT tag instead of a SELECT tag but the allowClear option requires a blank OPTION tag inside the SELECT tag.
Is there a way to use the ajax properties AND the allowClear option? If so, how? If not, then maybe this is a feature request.
Thanks.
The text was updated successfully, but these errors were encountered: