diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-02-28 15:15:32 +0100 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-02-28 16:08:59 +0100 |
commit | 811b377aad83f97a817542bd9d9eda957beab99d (patch) | |
tree | 4a58c855cd38dbd1bd804dff2f7577d163b810aa /ui/jquery.ui.autocomplete.js | |
parent | 70de33ae6d32416b0167c34c1a9951acfaaaf992 (diff) | |
download | jquery-ui-811b377aad83f97a817542bd9d9eda957beab99d.tar.gz jquery-ui-811b377aad83f97a817542bd9d9eda957beab99d.zip |
Update data naming for autocomplete. Backwards compatible for overrides of _renderItem. Partial fix for #7810
Diffstat (limited to 'ui/jquery.ui.autocomplete.js')
-rw-r--r-- | ui/jquery.ui.autocomplete.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index e261b9147..83326e27f 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -225,7 +225,8 @@ $.widget( "ui.autocomplete", { // custom key handling for now input: $(), focus: function( event, ui ) { - var item = ui.item.data( "item.autocomplete" ); + // back compat for _renderItem using item.autocomplete + var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ); if ( false !== self._trigger( "focus", event, { item: item } ) ) { // use value to match what will end up in the input, if it was a key event if ( /^key/.test(event.originalEvent.type) ) { @@ -234,7 +235,8 @@ $.widget( "ui.autocomplete", { } }, select: function( event, ui ) { - var item = ui.item.data( "item.autocomplete" ), + // back compat for _renderItem using item.autocomplete + var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ); previous = self.previous; // only trigger when focus was lost (click on menu) @@ -470,13 +472,16 @@ $.widget( "ui.autocomplete", { _renderMenu: function( ul, items ) { var self = this; $.each( items, function( index, item ) { - self._renderItem( ul, item ); + self._renderItemData( ul, item ); }); }, - _renderItem: function( ul, item) { + _renderItemData: function( ul, item ) { + return this._renderItem( ul, item ).data( "ui-autocomplete-item", item ); + }, + + _renderItem: function( ul, item ) { return $( "<li></li>" ) - .data( "item.autocomplete", item ) .append( $( "<a></a>" ).text( item.label ) ) .appendTo( ul ); }, |