From e842797aaf9beb0327a106b92ae5f412ee0b455f Mon Sep 17 00:00:00 2001 From: Stretch Date: Sun, 3 Jan 2016 19:06:13 -0500 Subject: [PATCH] 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 --- src/js/select2/data/tags.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/js/select2/data/tags.js b/src/js/select2/data/tags.js index a9b48cc9..db42faab 100644 --- a/src/js/select2/data/tags.js +++ b/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)) {