2017-10-02 2 views
0

materialize css 및 js를 사용하고 있으며 jQuery도 있습니다.구체화 자동 완료 안 함

입력란에 입력 할 때 (입력 type="text") 모든 항목이 올바르게 작동하지만 뭔가를 입력 한 다음 다른 항목을 클릭하면 (자동 완성이 닫히지 만) 그렇지 않은 경우입니다. 텍스트를 지울 때까지 이렇게있어.

enter image description here

내 코드 :

<input type="text" id="search" class="header-search-input" placeholder="Search" style="width: 320px !important;" autocomplete="off" /> 

와 JS 코드 :

$('#search').autocomplete({ 
      data: { 
       "Apple": 'https://maxcdn.icons8.com/Android_L/PNG/512/Operating_Systems/mac_os-512.png', 
       "Microsoft": 'http://www.freeiconspng.com/uploads/microsoft-new-logo-simple-0.png', 
       "Google": 'https://maxcdn.icons8.com/Share/icon/Logos//google_logo1600.png' 
      }, 
      limit: 20, // The max amount of results that can be shown at once. Default: Infinity. 
      onAutocomplete: function (val) { 
       // Callback function when value is autcompleted. 
      }, 
      minLength: 1, // The minimum length of the input for the autocomplete to start. Default: 1. 
     }); 

답변

0

당신은 입력 자동 완성 클래스를 추가하고이 "자동 완성 ="해제 "를 제거해야합니다.

<input type="text" id="search" class="autocomplete"> 

이 JS을 시도해보십시오

$('input#search').autocomplete({......................}); 

는 또한 도서관 JS의 순서에는, 먼저 jquery.min.js 후 materialize.min.js. body 태그가 닫히기 전에 모두해야합니다.

관련 문제