j-SearchBox
The component contains a search box (input).
Configuration:
exec {String}a link to thefunction(model, component, changetype), it will be executed if the user presses enterautocomplete {String}a link to thefunction(component, input), it will be executed if the user focuses the search boxinit {String}a link to thefunction(component), it will be executed if the component is initializedplaceholder {String}a placeholder for the search boxcleartype {Boolean}clears type when the user will performESC(default:false)keypress {Boolean}key-press binding (default:false)autotrim {Boolean}trims the value automatically (default:true)clicktype {String}a link to thefunction(component, currenttype, currentvalue), it will be executed if the user clicks on thetype(a newtypemust be set viacomponent.type(html, value))
Methods:
component.type(html, id, [noemit])adds a new type before the search inputcomponent.enter()performs searching manually- NEW:
component.show()focuses the input
Use it with <ui-component name="searchbox">. 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="menu"></ui-component>
<ui-component name="searchbox" config="exec:searchbox_enter;clicktype:searchbox_type;init:searchbox_init;placeholder:Search and press enter ..."></ui-component>
<script>
function searchbox_enter(model, component) {
// model.type
// model.value
alert(model.type + ': ' + model.value);
}
function searchbox_init(component) {
component.type('<i class="ti ti-user"></i> By name', 'name', true);
}
function searchbox_type(component) {
var opt = {};
opt.items = [{ name: 'By name', value: 'name', icon: 'user' }, { name: 'By subject', value: 'subject', icon: 'text-width' }, { name: 'By body', value: 'body', icon: 'file-alt' }];
opt.align = 'left';
opt.element = component.element;
opt.callback = function(selected) {
component.type('<i class="ti ti-{0}"></i> {1}'.format(selected.icon, selected.name), selected.value, true);
};
SETTER('menu', 'show', opt);
}
</script>