Parcourir la source

Merge branch 'docs-for-ajax-results-looks-like' of https://github.com/sedrubal/select2

alexweissman il y a 7 ans
Parent
commit
f13ea6f5ff
1 fichiers modifiés avec 11 ajouts et 1 suppressions
  1. 11 1
      docs/_includes/options/data/ajax.html

+ 11 - 1
docs/_includes/options/data/ajax.html

@@ -19,7 +19,17 @@
     What should the results returned to Select2 look like?
     What should the results returned to Select2 look like?
   </h3>
   </h3>
 
 
-  {% include options/not-written.html %}
+  <p>
+  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>.
+  </p>
+
+{% highlight js linenos %}
+[
+  {id: 'id1', text: 'option1'},
+  {id: 'id2', text: 'option2'},
+  {id: 'id3', text: 'option3'},
+]
+{% endhighlight %}
 
 
   <h3>
   <h3>
     Is there a way to modify the response before passing it back to Select2?
     Is there a way to modify the response before passing it back to Select2?