소스 검색

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 10 년 전
부모
커밋
e842797aaf
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  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)) {