自动完成功能在使用数据表的动态添加行中不起作用 [英] Autocomplete wont work in dynamic added rows using datatable

查看:84
本文介绍了自动完成功能在使用数据表的动态添加行中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文本框中添加了自动完成功能,但是我单击添加按钮,然后添加了新行,但自动完成功能无效。以下是我的代码。



我尝试过:



$ (function(){

$(#skills)。autocomplete({

source:'textbox_auto_complete.php'

});

});



//添加剧本



$(' #product_table')。DataTable();

$(document).on(click,#addRow,function(){

var table = $( '#product_table')。DataTable();

table.row.add(['','',''])。draw();

}) ;



// html

< table id =product_tableclass =displaycellspacing =0width =50 %>

< thead>

< tr>

< th align =Center>产品名称< / th>

< th align =Center> Quantity< / th>

< th align =Center>点击我< / th>

< / tr>

< / THEAD>

< tbody>

< tr>

< td>< input class =product_text skillstype =text placeholder =Type Product Namename =skillsid =skillsrequired =>

< / td>

< span id =所属类别>< /跨度>

< td>< input class =product_texttype =textplaceholder =Quantityname =Quantityrequired =>< / td>

< td>< input class =product_texttype =buttonid =addRowname =addRowvalue =Add>< / td>

< / tr>

< / tbody>

< / table>

I have added autocomplete feature in my textbox but I click Add button then new row added but autocomplete wont work. below is my code.

What I have tried:

$(function() {
$("#skills").autocomplete({
source: 'textbox_auto_complete.php'
});
});

//Add Script

$('#product_table').DataTable();
$(document).on("click","#addRow",function(){
var table = $('#product_table').DataTable();
table.row.add(['','','']).draw();
});

//html
<table id="product_table" class="display" cellspacing="0" width="50%">
<thead>
<tr>
<th align="Center">Product Name</th>
<th align="Center">Quantity</th>
<th align="Center">Click Me</th>
</tr>
</thead>
<tbody>
<tr>
<td><input class="product_text skills" type="text" placeholder="Type Product Name" name="skills" id="skills" required="">
</td>
<span id="product_list"></span>
<td><input class="product_text" type="text" placeholder="Quantity" name="Quantity" required=""></td>
<td><input class="product_text" type="button" id="addRow" name="addRow" value="Add"></td>
</tr>
</tbody>
</table>

推荐答案

( function(){
(function() {


(#skills)。autocomplete({

source:'textbox_auto_complete.php'

});

});



//添加剧本


("#skills").autocomplete({
source: 'textbox_auto_complete.php'
});
});

//Add Script


('#product_table')。DataTable();
('#product_table').DataTable();


这篇关于自动完成功能在使用数据表的动态添加行中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆