1
0
mirror of synced 2024-11-22 04:56:08 +03:00

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:
Kevin Brown 2015-03-14 20:36:06 -04:00
parent 5a25c33fc5
commit a06379ce8d
6 changed files with 16 additions and 7 deletions

View File

@ -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');

File diff suppressed because one or more lines are too long

5
dist/js/select2.js vendored
View File

@ -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');

File diff suppressed because one or more lines are too long

View File

@ -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>

View File

@ -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');