From 2cd10ba8a44a75ead882273c650fcf85ff4cb0c3 Mon Sep 17 00:00:00 2001 From: Jeanmonod David Date: Sat, 25 Jan 2014 01:18:13 +0100 Subject: [PATCH] Documentation for PR #2070 --- select2-latest.html | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/select2-latest.html b/select2-latest.html index e3dacad5..06de22f9 100644 --- a/select2-latest.html +++ b/select2-latest.html @@ -1366,6 +1366,26 @@ format(item) { must be taken to sanitize the id attribute of the choice object, especially stripping , as it is used as a value separator.

+ createSearchChoicePositionstring|function + Define the position where to insert element created by createSearchChoice. The following values are supported: +
+
top
Insert in the top of the list
+
bottom
Insert at the end of the list
+
<function>
+
+

A custom function. For example if you want to insert the new item in the second position:

+
+$("#tags").select2({
+    ...
+    createSearchChoice: function(term) { ... },
+    createSearchChoicePosition: function(list, item) {
+        list.splice(1, 0, item);
+    }
+});
+
+
+
+ initSelectionfunction Called when Select2 is created to allow the user to initialize the selection based on the value of the element select2 is attached to.