From 250885d78911516893e0978eaa306975a3f0a173 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Wed, 27 Jun 2012 21:49:39 -0700 Subject: [PATCH] catch up to master --- .gitignore | 3 +++ select2-latest.html | 25 ++++++++++++------------- select2-master | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 73e1499e..72d3ee5b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ .DS_Store select2wip _site +.project +.classpath +.settings diff --git a/select2-latest.html b/select2-latest.html index f6564f19..06715bc5 100755 --- a/select2-latest.html +++ b/select2-latest.html @@ -496,7 +496,7 @@ $("#e2_2").select2({ - +

Loading Remote Data

@@ -760,13 +760,13 @@ $("#e17").select2({ - - + + - - + +
@@ -808,7 +808,7 @@ $("#e17").select2({ non-multi-value select boxes an empty first option element must be provided (<option></option>) for the placeholder to work.

- +

When Select2 is used in multi-select mode the placeholder must be a string.

@@ -932,7 +932,7 @@ $("#e17").select2({ If the function returns undefined or null no choice will be created. If a new choice is created it is displayed first in the selection list so that user may select it by simply pressing enter. - +

When used in combination with input[type=hidden] tag care must be taken to sanitize the id attribute of the choice object, especially stripping , as it is used as a value separator

@@ -943,24 +943,23 @@ $("#e17").select2({

Essentially this is an id->object mapping function.

-
initSelection(element)
+
initSelection(element, callback)
- +
ParameterTypeDescription
elementjQuery arrayelement Select2 is attached to
<returns>object or array of objectsObject representing the choice - to be selected, or an array of such objects in case Select2 is in multi mode.
callbackfunctioncallback function that should be called with the data which is either an object in case of a single select or an array of objects in case of multi-select

This function will only be called when there is initial input to be processed.

Here is an example implementation used for tags. Tags are the simplest form of data where the id is also the text:
 $("#tags").select2({
-    initSelection : function (element) {
+    initSelection : function (element, callback) {
         var data = [];
         $(element.val().split(",")).each(function () {
             data.push({id: this, text: this});
         });
-        return data;
+        callback(data);
     }
 });
 
@@ -1128,6 +1127,6 @@ $("#tags").select2({

- + diff --git a/select2-master b/select2-master index 7ec2dec9..45442aa8 160000 --- a/select2-master +++ b/select2-master @@ -1 +1 @@ -Subproject commit 7ec2dec955e7b4065777cc3278e9e95fad7ea2bf +Subproject commit 45442aa8d7a4aabb62733f22d28ec0a72cee786f