Normalize ids to string for remote data
This also fixes an issue where we were using the `full_name` for the value instead of the `id` in the example, which technically wasn't correct. This closes https://github.com/select2/select2/issues/3148.
This commit is contained in:
parent
5a25c33fc5
commit
a06379ce8d
5
dist/js/select2.full.js
vendored
5
dist/js/select2.full.js
vendored
@ -825,7 +825,10 @@ S2.define('select2/results',[
|
||||
|
||||
var item = $.data(this, 'data');
|
||||
|
||||
if ($.inArray(item.id, selectedIds) > -1) {
|
||||
// id needs to be converted to a string when comparing
|
||||
var id = '' + item.id;
|
||||
|
||||
if ($.inArray(id, selectedIds) > -1) {
|
||||
$option.attr('aria-selected', 'true');
|
||||
} else {
|
||||
$option.attr('aria-selected', 'false');
|
||||
|
2
dist/js/select2.full.min.js
vendored
2
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
5
dist/js/select2.js
vendored
5
dist/js/select2.js
vendored
@ -825,7 +825,10 @@ S2.define('select2/results',[
|
||||
|
||||
var item = $.data(this, 'data');
|
||||
|
||||
if ($.inArray(item.id, selectedIds) > -1) {
|
||||
// id needs to be converted to a string when comparing
|
||||
var id = '' + item.id;
|
||||
|
||||
if ($.inArray(id, selectedIds) > -1) {
|
||||
$option.attr('aria-selected', 'true');
|
||||
} else {
|
||||
$option.attr('aria-selected', 'false');
|
||||
|
2
dist/js/select2.min.js
vendored
2
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
@ -231,7 +231,7 @@ $(".js-example-data-array-selected").select2({
|
||||
|
||||
<p>
|
||||
<select class="js-example-data-ajax form-control">
|
||||
<option value="select2/select2" selected="selected">select2/select2</option>
|
||||
<option value="3620194" selected="selected">select2/select2</option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
@ -291,7 +291,7 @@ $(".js-data-example-ajax").select2({
|
||||
|
||||
<script type="text/x-example-code" class="js-code-data-ajax-html">
|
||||
<select class="js-data-example-ajax">
|
||||
<option value="select2/select2" selected="selected">select2/select2</option>
|
||||
<option value="3620194" selected="selected">select2/select2</option>
|
||||
</select>
|
||||
</script>
|
||||
</div>
|
||||
|
5
src/js/select2/results.js
vendored
5
src/js/select2/results.js
vendored
@ -106,7 +106,10 @@ define([
|
||||
|
||||
var item = $.data(this, 'data');
|
||||
|
||||
if ($.inArray(item.id, selectedIds) > -1) {
|
||||
// id needs to be converted to a string when comparing
|
||||
var id = '' + item.id;
|
||||
|
||||
if ($.inArray(id, selectedIds) > -1) {
|
||||
$option.attr('aria-selected', 'true');
|
||||
} else {
|
||||
$option.attr('aria-selected', 'false');
|
||||
|
Loading…
Reference in New Issue
Block a user