Autocomplete

To use the autocomplete add the class.autocompleteto an input element, then set attributedata-urlto assign remote url to call for data, the key is passed as post.         

The server response must be an array of arrays encoded in json

json

[
    {
     "label": "rosa"
     "html": "<a href='/docs'>test</a>"
    },
    {
     "label": "rosa"
    }
]


label represents the label to insert into the input, instead of text or html is the code to draw inside the tip

Example:

javascript

Once you have selected a row an event is thrown javascriptselected which You can add a bind, as parameters of the function is the event, and an array containing the value selected and the selected item.

zjs('.autocomplete').bind('selected', function(e, value){
    alert('Selected value: '+value[0]);
});

Autocomplete with image

json

[
    {
     "label":"alimentatore tv",
     "value": 10,
     "html": "<a><img src='img1.jpg'/>item1 <span>€ 10,00</span></a>"},
    {
     "label":"mouse ottico",
     "value": 35,
     "html": "<a><img src='img2.png'/>item2 <span>€ 4,00</span></a>"}
]


value represents the value, instead of text or html is the code to draw inside the tip

If you want set a min-length trigger before your remote request, you can use data-min-length attribute

If you want send extra params you can usedata-paramsattribute