ForgeComponents
en

Components

j-Choose

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20

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.

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>