j-Suggestion
- admite 3 orientaciones
left,centeryright - singleton
- funciona con el sistema Bootstrap Grid
- funciona con toques
- admite modo oscuro
Métodos:
Método: component.show(orientation, targetElement, [items/function(search, next)], clickCallback)
orientation {String}puede serleft,centerorighttargetElement {Selector/jQuery/Element}un objetivo donde el componente será visibleitems {Array}es opcional y debe tener esta estructura:[{ name: String, value: String, icon: String }], de lo contrario, los elementos se leerán desde el atributodata-optionsdel objetivo.callback(selectedItem) {Function}se activa cuando el usuario hace clic en el elemento
Método: component.hide()
Atributos:
targetElementpuede contener el atributodata-options="Name 1|ti-building|Value 1;Name 2|ti-github|Value 2;"con todos los elementos del menú contextual.
Configuración:
placeholder- un marcador de posición para la entrada de búsqueda
Búsqueda del lado del servidor:
SETTER('suggestion', 'show', element, function(search, next) {
next([{ name: 'Item 1' }, { name: 'Item 2' }]);
}, function(selected) {
console.log(selected);
});Si value no está definido, entonces el componente usa name como value.
Eventos globales:
ON('suggestion', function(visible, component, target) {
console.log('Suggestion is', visible ? 'visible' : 'hidden');
});Úselo con <ui-component name="suggestion">. Cuando el componente aún no está cargado, jComponent lo descarga en el primer uso desde la dirección en DEF.fallback (el CDN Componentator de forma predeterminada). Autor: Peter Širka. Fuente: repositorio de componentes Componentator, licencia MIT.
<style>
body { background-color: #F0F0F0; }
</style>
<ui-component name="suggestion" config="placeholder:Search ..."></ui-component>
<div class="container">
<a href="javascript:void(0)">Suggest</a>
</div>
<script>
$(document).on('click', 'a', function() {
SETTER('suggestion/show', 'left', this, [{ name: 'Total.js' }, { name: 'Express.js' }, { name: 'Meteor.js' }, { name: 'Koa.js' }, { name: 'ASP.NET' }, { name: 'PHP' }, { name: 'Python' }, { name: 'Node.js' }], function(value) {
console.log('CLICK', value);
});
});
</script>