============= Configuration ============= Options can be passed in an object as the second argument to ``dropulous(target, options)``, or set via ``data-`` attributes on the ``input`` or ``select`` element. ``source`` URL of an API endpoint to load options from. Called with ``?q=`` on each keystroke. Must return ``{"options": [{value, label}, ...]}`` - see :ref:`From an API ` for the full response format. * Data attribute: ``data-source`` ``canAdd`` Allow the user to create new options not in the list. * Data attribute: ``data-can-add``. * Default: ``false``. ``minQueryLength`` Minimum number of characters the user must type before an API request is sent. Has no effect when options are loaded locally. * Data attribute: ``data-min-query-length``. * Default: ``0``. ``debounceTime`` Milliseconds to wait after the last keystroke before sending an API request. * Data attribute: ``data-debounce-time``. * Default: ``300``. ``formatOption`` Function called to render each option in the dropdown. Receives a ``Dropulous.Option`` and must return an HTML string. See :ref:`formatters`. ``formatSelected`` Function called to render each selected item. Receives a ``Dropulous.Option`` and must return an HTML string. See :ref:`formatters`. ``templates`` Object of HTML template strings to override the default markup. See :ref:`templates`. Initial values ============== For ```` elements, the initial value is read from the ``value`` attribute, or the ``data-value`` attribute (if set, takes priority over ``value``). For multiple-selection inputs, supply a comma-separated string: .. code-block:: html When using an API source on a `` .. _formatters: Custom formatters ================= ``formatOption`` and ``formatSelected`` are methods that receive a ``Dropulous.Option`` object and return an HTML string. ``formatOption`` controls how options appear in the open dropdown; ``formatSelected`` controls how selected values appear in the control. A ``Dropulous.Option`` has: - ``value`` - the option's value string - ``label`` - the plain-text label, used for search matching and aria labels - ``html`` - optional pre-rendered markup to display instead of the escaped ``label`` - ``data`` - an object of extra data (from ``data-*`` attributes on ``