Autocomplete requires you to click twice in iOS after update to 1.11.0

前端 未结 12 1198
野趣味
野趣味 2020-12-01 02:41

Using jQuery 2.1.0 and jQuery.ui 1.11.0 Tested in iOS 7. iPhone and iPad Mini. Works on android and regular browsers.

The problem

We recently upgraded from

12条回答
  •  没有蜡笔的小新
    2020-12-01 03:16

    $.ajax({
     url: '/ajax/xyz.json'
    })
    .done(function( data ) {
      $('#id').autocomplete({
        source: data,
        open: function( event, ui ) {
            if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
              $('.ui-autocomplete').off('menufocus hover mouseover mouseenter');
            }
        },
        select: function( event, ui ) {
          window.location.href = ui.item.value;
          return false;
        }
      });
    });
    

    This worked for me (works on drupal 8 as well). Now one tap on iOS devices redirect to search result page.

提交回复
热议问题