From 2537b8b0dd35c810c133f5d8d858eaa0f64dc10d Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Thu, 28 Jun 2012 02:32:37 -0700 Subject: [PATCH] doc hierarchical format. fixes #169 --- select2-latest.html | 31 ++++++++++++++++++++++++++++++- select2-master | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/select2-latest.html b/select2-latest.html index 06715bc5..4347acf2 100755 --- a/select2-latest.html +++ b/select2-latest.html @@ -979,13 +979,42 @@ $("#tags").select2({ Callback function that should be called with the result object. The result object: - +
ParameterTypeDescription
result.results[object]Array of result objects. The default renderers expect objects with id and text keys. The id attribute is required, even if custom renderers are used.
result.results[object]Array of result objects. The default renderers expect objects with id and text keys. The id attribute is required, even if custom renderers are used. The object may also contain a childrenkey if hierarchical data is displayed.
result.morebooleantrueif more results are available for the current search term
results.contextobjectA user-defined object that should be made available as the context parameter to the query function on subsequent queries to load more result pages for the same search term. See the description of options.context parameter.

In order for this function to work Select2 should be attached to a input type='hidden' tag instead of a select.

+

+

Example Data

+
+{
+     more: false,
+     results: [
+        { id: "CA", text: "California" },
+        { id: "AL", text: "Alabama" }
+     ]
+}
+                        
+

+

+

Example Hierarchical Data

+
+{
+    more: false,
+    results: [
+        { text: "Western", children: [
+            { id: "CA", text: "California" },
+            { id: "AZ", text: "Arizona" }
+        ] },
+        { text: "Eastern", children: [
+            { id: "FL", text: "Florida" }
+        ] }
+    ]
+}
+                        
+

ajaxobject diff --git a/select2-master b/select2-master index 45442aa8..89ee75dd 160000 --- a/select2-master +++ b/select2-master @@ -1 +1 @@ -Subproject commit 45442aa8d7a4aabb62733f22d28ec0a72cee786f +Subproject commit 89ee75dd9d809d5bec923109330f6b6b6517aca1