简体   繁体   中英

jQuery UI autocomplete $.widget not working

I'm trying to extend ui.autocomplete by using widget factory:

$.widget( "custom.myautocomplete", $.ui.autocomplete, {
  _renderItem: function( ul, item ) {
    return $( "<li>" )
      .text(item.label)
      .appendTo( ul ); 
  }
});

$(function() {
  $("#inp").myautocomplete({
    minLength: 1,
    source: ["One","Two","Three","Four","Five"]
  })
});

Searching works fine, but item selection does not work.

JS Fiddle

Try using a later version of jquery. It works for me with 1.10 and 1.11

code unchanged

http://jsfiddle.net/L5uu393y/7/

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