# j-Selection

> The component supports something like checkbox list.

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

The component supports something like checkbox list.


__Configuration__:

- `remember {Boolean}` remembers selection when the `datasource` is changed (default: `true`)
- `datasource {String}` a path to the datasource (default: empty)
- `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`)
- `dblclickselectall {Boolean}` enables reverse selection after double-click (default: `true`)
- `cancel {String}` a path to the variable (if the variable is changed then the selection is resetted, default: empty)
- __NEW__: `click {String}` a selector for capturing of click (default: `.selection`)

__Methods__:

- `component.selectall()` selects all items
- `component.selectnone()` selects none
- `component.selecttoggle()` reverses selection

Use it with `<ui-component name="selection">`. 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>
	.items > div { height: 28px; line-height: 28px; border-bottom: 1px solid #E0E0E0; }
	.selection { width: 18px; height: 18px; font-size: 11px; border-radius: 3px; border: 1px solid #E0E0E0; text-align: center; float: left; cursor: pointer; margin: 4px 5px 0 0; }
	.selection i { display: none; line-height: 16px; }
	.selection.selected i { display: block; }
</style>

<ui-component name="selection" path="myselection" class="items m">
	<div><span class="selection" data-id="1"><i class="ti ti-check"></i></span>Item 1</div>
	<div><span class="selection" data-id="2"><i class="ti ti-check"></i></span>Item 2</div>
	<div><span class="selection" data-id="3"><i class="ti ti-check"></i></span>Item 3</div>
	<div><span class="selection" data-id="4"><i class="ti ti-check"></i></span>Item 4</div>
	<div><span class="selection" data-id="5"><i class="ti ti-check"></i></span>Item 5</div>
	<div><span class="selection" data-id="6"><i class="ti ti-check"></i></span>Item 6</div>
	<div><span class="selection" data-id="7"><i class="ti ti-check"></i></span>Item 7</div>
	<div><span class="selection" data-id="8"><i class="ti ti-check"></i></span>Item 8</div>
	<div><span class="selection" data-id="9"><i class="ti ti-check"></i></span>Item 9</div>
</ui-component>

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