j-KeySelection
This component allows user to select some items by up/down keys and confirm selection by the enter key.
- supports auto-scroll
Configuration
selectoritem {String}a selector for browsing items (default:.item)selector {String}a default selector for capturing keys (default:input)class {String}a selection class (default:selected)autoselect {Boolean}it should select first item (default:true)autoscroll {Boolean}enables/disables auto-scroll (default:true)exec {String}a link to thefunction(jqueryel), evaluated by theenterkey (optional, otherwise will be triggerclickevent)delay {Number}a delay for auto-selecting first valuedatasource {String}a link to the data-source that can help you with a dynamic list
Use it with <ui-component name="keyselection">. 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.
<style>
.selected { background: #F0F0F0; }
.item { line-height: 24px; padding: 0 10px; border-top: 1px solid #E0E0E0; font-size: 12px; }
</style>
<ui-component name="keyselection" config="exec:confirmselection">
<div class="m"><input type="text" placeholder="Press UP or DOWN key" style="width:300px" /></div>
<div class="items">
<div class="item" data-id="1">1</div>
<div class="item" data-id="1">2</div>
<div class="item" data-id="1">3</div>
<div class="item" data-id="1">4</div>
<div class="item" data-id="1">5</div>
</div>
</ui-component>
<script>
function confirmselection(el) {
console.log('selected', el);
}
</script>