Autocomplete and custom _renderItemData
Hi
I have tried to modifu format of item using _renderItemData (or _renderItem) and used with remote source , it works fine till user press Arrow up/down and i get error:
Uncaught TypeError: Cannot read property 'value' of undefined
L:6460
I have value field in my JSON source, when i remove _renderItemData , it works fine?
Thanks
P
- $.widget( "custom.beachcomplete", $.ui.autocomplete, {
- _renderMenu: function( ul, items ) {
- var that = this,
- currentCategory = "";
- $.each( items, function( index, item ) {
- if ( item.category != currentCategory ) {
- ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
- currentCategory = item.category;
- }
- that._renderItemData( ul, item );
- });
- },
- _renderItemData: function( ul, item ) {
- item.name = item.name.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
- return $("<li></li>")
- .data("item.autocomplete", item)
- .append( "" + item.name + " (" + item.state + ")" )
- .appendTo(ul);
- }
- });