2016-12-02 5 views
0

申し訳ありませんを取得しますが、私はTypeahead.jsはID

私の問題は、私が選択した製品のIDを取得することはできません..です回答を見つけることができません。値= 0が

マイコード:

$("#recherche").typeahead({ 
    onSelect: function(item) { 
     alert(item.value); // = 0 
    }, 
    ajax: { 
     url: "/personne/autocompletation", 
     displayField: "nomComplet", 
     triggerLength: 1, 
     method: "POST", 
     dataType: "JSON", 
     preDispatch: function (query) { 
      return { 
       query: query 
      } 
     } 
    }, 
}); 

私のコードのHTML私の英語のための

<li class="active" data-value="0"><a href="#"><strong>C</strong>alloway</a></li> 

申し訳ありません...

答えて

0

は試してみてください。この

$("#recherche").typeahead({ 
    source: function(query, process){ 
    $.ajax({ 
     url: "/personne/autocompletation", 
     displayField: "nomComplet", 
     triggerLength: 1, 
     method: "POST", 
     dataType: "JSON", 
     success: function (data) { 
      console.log(data); 
     } 
    }); 
    } 

}) ;

関連する問題