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

Add closeOnSelect:false and multiple:true, dropdown scroll to the first selected option when select multiple #4739

Closed
xiaoshi19890714 opened this issue Jan 6, 2017 · 2 comments

Comments

@xiaoshi19890714
Copy link

xiaoshi19890714 commented Jan 6, 2017

select2 version: 4.0.3
jquery version: 3.1.1
my code:
<select class="form-control" id="contact" name="contact"></select>

$("#contact").select2({
language: "zh-CN",
multiple: true,
dropdownParent: sendMsgSelectContactForm,
closeOnSelect: false,
placeholder: "Please select contact",
templateSelection: function (data, container) {
if (typeof (container) !== "undefined") {
$(data.element).attr('mobile', data.mobile);
$(data.element).attr('email', data.email);
}
return data.text;
},
ajax: {
url: sendMsgSelectContactForm.attr('getContactPath'),
dataType: "JSON",
type: "POST",
delay: 200,
cache: true,
data: function (params) {
params.page = params.page || 1;
let data = {};
return data;
},
processResults: function (data, params) {
params.page = params.page || 1;
var results = [];
$.each(result, function (index, obj) {
results.push({
id: obj.id.toString(),
text: obj.name
});
});
return {
results: results,
pagination: {
more: (params.page * 30) < parseInt(data.result.recordsTotal)
}
};
}
}
});

I need a multiple select , and i hope don't close dropdown option after click option.
The above method can satisfy my needs.
But, when I select options from top to bottom,after each click, dropdown will scroll to the location of the first option selected. I didn't find a better solution, I hope that after each click dropdown can stay in the click position.

@kevin-brown
Copy link
Member

Duplicate of #4417.

@hemant-rao
Copy link

any one find solution please share. As soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants