Web Component: j-MultiOptions


  • Info
  • HTML
  • JS
  • CSS
  • Meta

j-MultiOptions

  • Works with Bootstrap
  • It expects the whole object with key: value
  • HTML body of the jComponent has to be <script type="text/plain> with (JavaScript) mapping

Configuration:

  • rebind {Boolean} rebinds a path value according to the MultiOptions schema (default: true)

Mapping:

  • it's provided on immediately when the component is ready
  • it has to wrapped in <script type="text/plain">option();option();...</script>
  • mapping method: option(key, label, value, [type], [max], [min], [step])

Basic types:

  • type: string (when is the value string you don't need to define the type)
  • type: number (when is the value number you don't need to define the type)
  • type: boolean (when is the value boolean you don't need to define the type)
  • type: date (when is the value date you don't need to define the type)
  • NEW type: multiline renders textarea instead of input

Simple Array:

option('language', 'Language', 'sk', ['sk', 'en', 'de']);

Advanced Array:

option('language', 'Language', 1, [{ text: 'sk', value: 1}, { text: 'en', value: 2}, { text: 'de', value: 3}]);

Array from URL:

option('language', 'Language', 1, '/my/api/codelist/');
// It expects some "Array"

Colors:

MultiOptions component uses this color scheme: http://codepen.io/devi8/pen/lvIeh and the declaration below will show all colors in the widget settings.

option('background', 'Background', '#FC6E51', 'Color');

Good to know:

  • all properties not defined in mapping won't be shown
  • date type is linked by Calendar component
  • follow example
  • component.remap(js_code) can remap new configuration
  • component.dependencies() returns Object with all items key/value from dropdown lists

Author