Jquery Auto complete append link at the bottom

后端 未结 1 1108
暖寄归人
暖寄归人 2021-01-05 21:35

I am using jQuery auto-complete plugin in my web project. I want to show 3 element and after that i want to append \'see all results\' link to the bottom.

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-05 21:59

    Here is the demo,

    http://jsfiddle.net/muthkum/vqwBP/105/

    I hope you will figure out how to implement.

    Update: I managed to update your code,

    $( ".grid-search-box" ).autocomplete({
          minLength: 0,
          source: function(request, response) {
            var results = $.ui.autocomplete.filter(temp, request.term);
    
            response(results.slice(0, 3)); //show 3 items.
        },
        open: function(event, ui) {
            $('.ui-autocomplete').append('
  • See All Result
  • '); //See all results }, focus: function( event, ui ) { $( ".grid-search-box" ).val( ui.item.value ); return false; }, select: function( event, ui ) { $( ".grid-search-box" ).val( ui.item.value ); return false; } }).data( "autocomplete" )._renderItem = function( ul, item ) { return $( "
  • " ) .data( "item.autocomplete", item ) .append( "" + item.value + "" ) .appendTo( ul ); };

    Demo: http://jsfiddle.net/muthkum/vqwBP/106/

    0 讨论(0)
提交回复
热议问题