Skip to content

Commit 96f5f72

Browse files
committed
Merge branch 'master' of https://github.com/adw99/select2
Adds information about pagination data
1 parent f13ea6f commit 96f5f72

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

docs/_includes/options/data/ajax.html

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,30 @@ <h3>
2020
</h3>
2121

2222
<p>
23-
When you aren't using custom formatting functions (<code>templateResult</code> and <code>templateSelection</code> or <code>formatResults</code>) the data returned by the data provider or by <code>processResults</code> should be a list of objects. The objects should contain an <code>id</code> and a <code>text</code> property. The text property will be displayed. See <a href="#what-properties-are-required-on-the-objects-passed-in-to-the-ar">What properties are required on the objects passed in to the array?</a>.
23+
The data returned by the data provider or by <code>processResults</code> should be a JSON object containing an array of objects keyed by the <code>results</code> key.
2424
</p>
25-
26-
{% highlight js linenos %}
27-
[
28-
{id: 'id1', text: 'option1'},
29-
{id: 'id2', text: 'option2'},
30-
{id: 'id3', text: 'option3'},
31-
]
25+
<p>
26+
Each object should contain, <em>at a minimum</em>, an <code>id</code> and a <code>text</code> property. The text property will be displayed by default, unless you are using <code>templateResult</code> and <code>templateSelection</code> to customize the way options and selections are rendered.
27+
</p>
28+
<p>
29+
The response object may also contain <a href="examples.html#data-ajax">pagination data</a>, if you would like to use the "infinite scroll" feature. See <a href="#what-properties-are-required-on-the-objects-passed-in-to-the-ar">"What properties are required on the objects passed in to the array?"</a> for more information. A complete example is as follows:
30+
</p>
31+
{% highlight json linenos %}
32+
{
33+
"results": [
34+
{
35+
"id": "1",
36+
"text": "Option 1"
37+
},
38+
{
39+
"id": "2",
40+
"text": "Option 2"
41+
}
42+
],
43+
"pagination": {
44+
"more": true
45+
}
46+
}
3247
{% endhighlight %}
3348

3449
<h3>

0 commit comments

Comments
 (0)