ERP.Web/res/assets/plugins/select2/docs/_includes/options/data/array.html

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<section>
  <h2 id="data">
    Can I load data into Select2 using an array?
  </h2>

  <p>
    While Select2 is designed to be used with a <code>&lt;select&gt;</code> tag
    the data that is used to search through and display the results can be
    loaded from a JavaScript array using the <code>data</code> option. This
    option should be passed in during the initialization of Select2.
  </p>

{% highlight js linenos %}
$('select').select2({
  data: [
    {
      id: 'value',
      text: 'Text to display'
    },
    // ... more data objects ...
  ]
});
{% endhighlight %}

  <h3>
    What properties are required on the objects passed in to the array?
  </h3>

  <p>
    The <code>id</code> and <code>text</code> properties are required on each
    object, and these are the properties that Select2 uses for the internal
    data objects. Any additional paramters passed in with data objects will be
    included on the data objects that Select2 exposes.
  </p>

  <h3>
    Do the <code>id</code> properties have to be strings?
  </h3>

  <p>
    Because the <code>value</code> attributes on a <code>&gt;select&lt;</code>
    tag must be strings, the <code>id</code> property on the data objects must
    also be strings. Select2 will attempt to convert anything that is not a
    string to a string, which will work for most situations, but it is
    recommended to force all of your ids to strings ahead of time.
  </p>

  <h3>
    I can't select results with blank ids or an id of <code>0</code>!
  </h3>

  <p>
    See <a href="#do-the-id-properties-have-to-be-strings">Do the <code>id</code> properties have to be strings?</a>.
  </p>

  <h3>
    How should nested results be formatted?
  </h3>

  <p>

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。