如何使用两个数据(“自动完成”),即renderitem和调整大小

时间:2012-10-30 07:27:26

标签: jquery jquery-ui jquery-plugins autocomplete jquery-autocomplete

$(".someClassWithMultipleItemsOnDOM").autocomplete({

        minLength:2,
        source .....(ajax call)
        .....   
}).focus( function() {
            /*some code*/

        })
.data( "autocomplete" )._renderItem = function( ul, item ) {
/*render item for making search text bold*/

};
.data("autocomplete")._resizeMenu = function () {
        /*resize code to set the size of autocosearch drop down box*/
        };

我在调整大小菜单行时收到错误,有语法错误,有没有办法同时使用这两个功能。以类似的方式。

1 个答案:

答案 0 :(得分:3)

您可以像这样同时使用_renderItem和_resizeMenu。

  var tag = $("#domId").autocomplete({
              source:...........
   });
  tag.data("autocomplete")._renderItem = function (ul, item) {
              /* Your code*/
   };
  tag.data("autocomplete")._resizeMenu = function () {
              /* Your code*/
   };

看一下这个网站JQFAQ,它对jQuery开发者来说会更有用。