gpt4 book ai didi

javascript - Typeahead 和第一个单元格选择器

转载 作者:行者123 更新时间:2023-11-30 21:04:37 25 4
gpt4 key购买 nike

我有这张 table

<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 因为我动态添加行,需要刷新 typehead...

最佳答案

我假设您正在使用这个 https://github.com/running-coder/jquery-typeahead

此插件需要在输入字段上初始化。因此,假设您的输入字段位于标题后第一行的第一列中,则选择器将是

$('#vehicleParamTable tbody tr td:first-child input').typeahead({ ...options })

关于javascript - Typeahead 和第一个单元格选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46773377/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com