2017-10-16 12 views
1

私は、この表は、先行入力された文字と最初のセル選択

<table id="vehicleParamTable" class="table table-striped"> 
    <thead> 
     <tr> 
      <th>Name</th> 
      <th>Description</th> 
     </tr> 
    </thead> 
    <tbody> 
    </tbody>  
</table> 

を持っています。それはうまく動作します。行の最初の列に

、Iは、第1行の(目ヘッダ)それを回避したいと思い、jqueryの-typehead

セレクタが動作していない追加

$('#vehicleParamTable tr td:first-child').typeahead({ 
    minLength: 2, 
    display: "name", 
    mustSelectItem: true, 
    emptyTemplate: function(query) { 
    //must reset current element here 
    return 'No result for "' + query + '"'; 
    }, 
    source: { 
    vehicleParam: { 
     ajax: { 
     url: "/rest/vehicleparam", 
     path: "content" 
     } 
    } 
    }, 
    callback: { 
    onEnter: function(node, a, item, event) { 
     //must assign item.id to current current element id 
    }, 
    onResult: function(node, query, result, resultCount, resultCountPerGroup) { 
     if (resultCount < 1) { 
     //must reset current element here 
     } 
    } 
    } 
}); 

編集

$('#vehicleParamTable tr td:first-child')

は良いように見えるが、未定義

を返し、残り(先行入力のinit ...)と

編集2動的に行を追加するため、タイプヘッドをリフレッシュする必要があります...

答えて

1

私はあなたがこれを使用していると仮定していますかhttps://github.com/running-coder/jquery-typeahead

このプラグインは入力フィールドで初期化する必要があります。 入力フィールドがヘッダーの後の最初の行の最初の列にある場合、セレクターは

$('#vehicleParamTable tbody tr td:first-child input').typeahead({ ...options }) 
となります
関連する問題