2017-10-02 4 views
0

私はマテリアライズ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。ボディータグを閉じる前にすべてが行かなければなりません。

関連する問題