# j-Choose

> The component is alternative to CheckboxListExpert and RadioButtonListExpert.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: d97d49258dd12977f00a1cfec05abc5d69f22550424aa28c6f280ed3d7cfd106
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

The component is alternative to `CheckboxListExpert` and `RadioButtonListExpert`.


__Configuration__:

- `limit {Number}` selection limit, `1` will return a value, `>1` will return array of values (default: `1`)
- `datasource {String}` a path to the datasource (default: empty)
- `required {Boolean}` enables validation (default: `false`)
- `key {String}` an `identifier` key name for the datasource (default: `id`)
- `attr {String}` a `data-[attr]` for storing of `identifier` (default: `id`)
- `selector {String}` a jQuery selector for elements (default: `.selection`)
- `class {String}` selected class (default: `selected`)
- `type {String}` converting type, supports `string` or `number` (default: `string`)
- `uncheck {Boolean}` allows to uncheck selected value for `limit:1` (default: `false`)
- `disabled {Boolean}` disables the component
- `click {String}` a link to the `function(val)` that is evaluted when the user changes the value
- __NEW__: `indexer {String}` a HTML selector for binding of the selected index

Use it with `<ui-component name="choose">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
<style>
	.iconmenu { height: 60px; text-align: center; }
	.iconmenu i { font-size: 20px; display: block; padding: 10px 0 0; }
	.iconmenu span { font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 5px 0; color: #777; }
	.iconmenu > div.selected { background-color: rgba(0,0,0,0.07); }
	.iconmenu > div { height: 60px; width: 75px; border: 1px solid #E0E0E0; border-left-width: 0; float: left; cursor: pointer; }
	.iconmenu > div:first-child { border-left-width: 1px; border-top-left-radius: var(--radius); border-bottom-left-radius: var(--radius); }
	.iconmenu > div:last-child { border-top-right-radius: var(--radius); border-bottom-right-radius: var(--radius); }
</style>

<ui-component name="choose" path="myselectionsingle" config="selector:div;limit:1" class="iconmenu m">
	<div data-id="male">
		<i class="ti ti-male"></i>
		<span>Male</span>
	</div>
	<div data-id="female">
		<i class="ti ti-female"></i>
		<span>Female</span>
	</div>
</ui-component>

<ui-component name="choose" path="myselectionmultiple" config="selector:div;limit:2;indexer:b" class="iconmenu m">
	<div data-id="male">
		<i class="ti ti-male"></i>
		<span>Male</span><b></b>
	</div>
	<div data-id="female">
		<i class="ti ti-female"></i>
		<span>Female</span><b></b>
	</div>
	<div data-id="unknown">
		<i class="ti ti-question-circle"></i>
		<span>Unknown</span><b></b>
	</div>
</ui-component>

<div>Output single: <code><ui-bind path="myselectionsingle" config="text:JSON.stringify(value)"></ui-bind></code></div>
<div>Output multiple: <code><ui-bind path="myselectionmultiple" config="text:JSON.stringify(value)"></ui-bind></code></div>
```
