Преглед изворни кода

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.
Kevin Brown пре 10 година
родитељ
комит
a06379ce8d
6 измењених фајлова са 14 додато и 5 уклоњено
  1. 4 1
      dist/js/select2.full.js
  2. 0 0
      dist/js/select2.full.min.js
  3. 4 1
      dist/js/select2.js
  4. 0 0
      dist/js/select2.min.js
  5. 2 2
      docs/examples.html
  6. 4 1
      src/js/select2/results.js

+ 4 - 1
dist/js/select2.full.js

@@ -825,7 +825,10 @@ S2.define('select2/results',[
 
 
         var item = $.data(this, 'data');
         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');
           $option.attr('aria-selected', 'true');
         } else {
         } else {
           $option.attr('aria-selected', 'false');
           $option.attr('aria-selected', 'false');

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
dist/js/select2.full.min.js


+ 4 - 1
dist/js/select2.js

@@ -825,7 +825,10 @@ S2.define('select2/results',[
 
 
         var item = $.data(this, 'data');
         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');
           $option.attr('aria-selected', 'true');
         } else {
         } else {
           $option.attr('aria-selected', 'false');
           $option.attr('aria-selected', 'false');

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
dist/js/select2.min.js


+ 2 - 2
docs/examples.html

@@ -231,7 +231,7 @@ $(".js-example-data-array-selected").select2({
 
 
       <p>
       <p>
         <select class="js-example-data-ajax form-control">
         <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>
         </select>
       </p>
       </p>
 
 
@@ -291,7 +291,7 @@ $(".js-data-example-ajax").select2({
 
 
 <script type="text/x-example-code" class="js-code-data-ajax-html">
 <script type="text/x-example-code" class="js-code-data-ajax-html">
 <select class="js-data-example-ajax">
 <select class="js-data-example-ajax">
-  <option value="select2/select2" selected="selected">select2/select2</option>
+  <option value="3620194" selected="selected">select2/select2</option>
 </select>
 </select>
 </script>
 </script>
     </div>
     </div>

+ 4 - 1
src/js/select2/results.js

@@ -106,7 +106,10 @@ define([
 
 
         var item = $.data(this, 'data');
         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');
           $option.attr('aria-selected', 'true');
         } else {
         } else {
           $option.attr('aria-selected', 'false');
           $option.attr('aria-selected', 'false');

Неке датотеке нису приказане због велике количине промена