j-SearchData
This component tries to filter data according to the search phrase.
Configuration:
datasource {String}required - a path to the data-source with list of itemsArrayoutput {String}required - a path for filtered itemskey {String}required - a key/property name for searching (default:name)delay {Number}a delay (default:50ms)splitwords {Boolean}tries to find word in various position (default:true)
Good to know:
This component adds classes below automatically when:
- class
ui-search-usedis added when the user searches for something - class
ui-search-emptyis added when the user searches for something and at the same time nothing was found
Use it with <ui-component name="searchdata">. 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.
<ui-component name="textbox" path="search" config="type:search"></ui-component>
<br />
<ui-component name="searchdata" path="search" config="datasource:searchitems;output:searchoutput">
<ui-bind path="searchoutput" config="template" class="block">
<script type="text/html">
{{ foreach m in value }}
<div>{{ m.name }}</div>
{{ end }}
</script>
</ui-bind>
</ui-component>
<script>
// Search phrase
var search = '';
// Datasource for filtering
var searchitems = [{ name: 'Apples' }, { name: 'Oranges' }, { name: 'Pears' }, { name: 'Black-eye bean' }, { name: 'Broccoli' }];
// Here will be stored all filtered items
var searchoutput = [];
</script>