简体   繁体   中英

jquery ui autocomplete custom display if no results returned

how can I display a custom popup if no results are returned ?

I have managed to display a "no results" response if the term returned no results

    response:function(event, ui){


        if(!ui.content.length){

            var noResult = {value:'',label:'No results'};
            ui.content.push(noResult);

        }
    }

but how can I display a custom popup. I am trying to display a window with necessary fields to add the item if it doesn't exist.

so actually it was very easy...

$('#search').autocomplete({
    .....
}).data("ui-autocomplete")._renderItem = function (ul, item) {
    //customizeaza selection list-ul 
    return $("<li>")
        .data("item.autocomplete", item)
        .append("<input type='text' maxlength='3' size='3' /><a>" + item.label + "<br>" + item.den_prod + "</a>")
        .appendTo(ul)
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM