From 2537b8b0dd35c810c133f5d8d858eaa0f64dc10d Mon Sep 17 00:00:00 2001
From: Igor Vaynberg In order for this function to work Select2 should be attached to a
+ Callback function that should be called with the
result
object. The result object:
- Parameter Type Description
+ 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 children
key if hierarchical data is displayed.result.more boolean true
if more results are available for the current search termresults.context object A 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.input type='hidden'
tag instead of a select
.Example Data
+
+{
+ more: false,
+ results: [
+ { id: "CA", text: "California" },
+ { id: "AL", text: "Alabama" }
+ ]
+}
+
+
+
+{ + more: false, + results: [ + { text: "Western", children: [ + { id: "CA", text: "California" }, + { id: "AZ", text: "Arizona" } + ] }, + { text: "Eastern", children: [ + { id: "FL", text: "Florida" } + ] } + ] +} ++