【发布时间】:2017-10-16 15:03:48
【问题描述】:
我有这张桌子
<table id="vehicleParamTable" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
当点击链接时,我会添加一行。效果很好。
在该行的第一列中,我添加了一个 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')
看起来不错,但是其余的(typeahead init..)返回未定义
编辑2因为我动态添加行,需要刷新字头...
【问题讨论】:
标签: javascript jquery typehead