Javascript 提前输入和第一个单元格选择器
我有这张桌子Javascript 提前输入和第一个单元格选择器,javascript,jquery,typehead,Javascript,Jquery,Typehead,我有这张桌子 <table id="vehicleParamTable" class="table table-striped"> <thead> <tr> <th>Name</th> <th>Description</th> </tr> </thead> <tbody>
<table id="vehicleParamTable" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
名称
描述
单击链接时,我添加一行。那很好
在行的第一列中,我添加了一个jquery字体
选择器不起作用,也希望避免它出现在第一行(第th个标题)
$(“#车辆参数tr td:first child”)。提前键入({
最小长度:2,
显示:“名称”,
mustSelectItem:true,
emptyTemplate:函数(查询){
//必须在此处重置当前元素
返回“对于“'+query+'”没有结果”;
},
资料来源:{
车辆参数:{
阿贾克斯:{
url:“/rest/vehicleparam”,
路径:“内容”
}
}
},
回拨:{
onEnter:功能(节点、a、项、事件){
//必须将item.id分配给当前元素id
},
onResult:函数(节点、查询、结果、结果计数、结果计数组){
如果(结果计数<1){
//必须在此处重置当前元素
}
}
}
});
编辑
$(“#车辆参数tr td:first child”)
看起来不错,但是剩下的(typeahead init..)返回未定义
编辑2因为我添加了动态行,需要刷新字体…我假设您正在使用它 此插件需要在输入字段上初始化。 因此,假设您的输入字段位于标题后第一行的第一列中,那么选择器将是
$('#vehicleParamTable tbody tr td:first-child input').typeahead({ ...options })
$('#vehicleParamTable tbody tr td:first-child input').typeahead({ ...options })