Browse Source

Added insertTag to control the tag position

This adds an option called `insertTag` that controls the location within
the results where the tag is inserted. The function should take in the
results array and the tag, and should modify the array in-place to add
the tag to the results.

This closes https://github.com/select2/select2/issues/3420
This closes https://github.com/select2/select2/pull/4008
Stretch 9 years ago
parent
commit
e842797aaf
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/js/select2/data/tags.js

+ 6 - 0
src/js/select2/data/tags.js

@@ -10,6 +10,12 @@ define([
       this.createTag = createTag;
     }
 
+    var insertTag = options.get('insertTag');
+
+    if (insertTag !== undefined) {
+        this.insertTag = insertTag;
+    }
+
     decorated.call(this, $element, options);
 
     if ($.isArray(tags)) {