我曾经有这个:
$( "#glavnotursene" ).autocomplete({
delay: 0,
source: 'extrastuff.php?glavnotursene',
select: function( event, ui ) {
window.location = 'maps.php?id. ' + ui.item.nomer;
}
});
而且效果很好。当项目弹出并单击它们时,我被重定向到 maps.php 我决定也使用类别,所以我这样做了:
$.widget( "custom.catcomplete", $.ui.autocomplete, {
_renderMenu: function( ul, items ) {
var self = this,
currentCategory = "";
$.each( items, function( index, item ) {
if ( item.category != currentCategory ) {
ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
currentCategory = item.category;
}
self._renderItem( ul, item );
});
}
});
$( "#glavnotursene" ).catcomplete({
delay: 0,
source: 'extrastuff.php?glavnotursene',
select: function( event, ui ) {
window.location = 'maps.php?id. ' + ui.item.nomer;
}
});
并且选择不再起作用,因此人们不会被重定向。
我在用着:
jQuery UI - v1.10.0
jQuery v1.9.1