JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q23121F
  • License ISC

Custom Dropdown

Package Exports

  • choosy-js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (choosy-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

choosy-js

choosy-js is a Custom Dropdown component for Javascript.

Check an example here


Installation

npm i choosy-js

Usage

Import the module

import Choosy from 'choosy-js';

Create a new instance with the target ID selector

const choosyDropDown = new Choosy('[target-id]');

[target-id] is the parent element's ID where Choosy will be injected into.

Call the module's render method with a given options data

choosyDropDown.render({
    options: '[options-data]'
});

[options-data] is mondatory and it matches the JSON data needed to set the Choosy options list.

Choosy is expecting id and label as default properties for the JSON object. Nonetheless, you can define your custom properties in order to match your object, e.g.:

choosyDropDown.render({
    ...
    properties: ['key', 'value'],
});

In case you want to have an initial value to be selected by default by Choosy, you just need to define initialValue property to the render method and pass your value.

choosyDropDown.render({
    ...
    initialValue: '[initial-value]',
});