From 793811757bde7aca3e958d0a7834a08bcf51ac62 Mon Sep 17 00:00:00 2001 From: sedrubal Date: Sun, 30 Oct 2016 17:18:44 +0100 Subject: [PATCH] Docs for: What should the results returned to Select2 look like? --- docs/_includes/options/data/ajax.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/_includes/options/data/ajax.html b/docs/_includes/options/data/ajax.html index b23ec91e..45236592 100644 --- a/docs/_includes/options/data/ajax.html +++ b/docs/_includes/options/data/ajax.html @@ -19,7 +19,17 @@ What should the results returned to Select2 look like? - {% include options/not-written.html %} +

+ When you aren't using custom formatting functions (templateResult and templateSelection or formatResults) the data returned by the data provider or by processResults should be a list of objects. The objects should contain an id and a text property. The text property will be displayed. See What properties are required on the objects passed in to the array?. +

+ +{% highlight js linenos %} +[ + {id: 'id1', text: 'option1'}, + {id: 'id2', text: 'option2'}, + {id: 'id3', text: 'option3'}, +] +{% endhighlight %}

Is there a way to modify the response before passing it back to Select2?