2014-09-19 58 views
0
$(function() { 
    $("#customer_name").autocomplete({ 
    source: function(request, response) { 
     $.ajax({ 
      url: "/management/order/auto", 
      dataType: "json", 
      data: {name: request.term}, 
      success: function(data) { 
       var suggestions = []; 
       $.each(data, function(i, val) { 
        suggestions.push({ 
         label: val.name, 
         code: val.code, 
         id: val.id, 
        }); 
       }); 
       response(suggestions); 
      }, 
      }); 
     }, 
    select: function(e, ui) { 
     $('#customer_id').val(ui.item.id); 
     $('#customer_code').val(ui.item.code); 
    }, 
    maxShowItems: 5, 
    }); 
}); 

将maxShowItems添加到自动完成选项。它接受项目的最大高度的项目数量lis 我加<?php echo Asset::js('jquery.ui.autocomplete.scroll.min.js') ?>但它不起作用,感谢您的帮助。如何为jQuery自动完成添加滚动条

回答

0

您只需将overflow: scroll添加到#customer_name固定高度。

#customer_name {height: 100px;width: 300px;overflow: scroll;}
<div id="customer_name"> 
 
A web page (or webpage) is a web document that is suitable for the World Wide Web and the web browser. A web browser displays a web page on a monitor or mobile device. The web page is what displays, but the term also refers to a computer file, usually written in HTML or comparable markup language, whose main distinction is to provide hypertext that will navigate to other web pages via links. Web browsers coordinate web resources centered around the written web page, such as style sheets, scripts and images, to present the web page. 
 
</div>