这个函数在我的表中工作正常addSpecificationValue,我的问题是如何使一个新的行创建一个自动完成称为文件来显示来自MySQL的信息。我使用该令牌输入的脚本
[http://loopj.com/jquery-tokeninput/][1]
我开发了一个特定的函数,当我想创建一个新行以包含在自动完成的输入中时
它没有工作,在控制台内,没有消息。我认为自动完成没有被调用或者令牌输入有问题。
我不知道如何在ID为#specificationName" + specification_row
的新行中包含自动完成功能
我的技能有限
感谢您的帮助
$products_specification_ajax = OSCOM::link('products_specification_ajax');
<script type="text/javascript"><!--
var specification_row = $t;
$(document).ready(function() {
$("#specificationName" + specification_row).tokenInput("{$products_specification_ajax}",
{
tokenLimit: 1,
resultsLimit: 5,
onResult: function (results) {
$.each(results, function (index, value) {
value.name = value.id + " " + value.name;
});
return results;
}
});
});
function addSpecificationValue() {
html = '<tr id="specification-row' + specification_row + '">';
//specification_name
html += '<td>';
html += ' <input type="text" name="products_specification[' + specification_row + '][name]" value="" id="specificationName' + specification_row + '" class="form-control token-input" />';
html += '</td>';
//remove
html += ' <td class="text-md-right"><button type="button" onclick="$(\'#specification-row' + specification_row + '\').remove();" data-toggle="tooltip" title="Remove" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
html += '</tr>';
$('#specification tbody').append(html);
specification_row++;
}
</script>
<br />
EOD;
[1]: http://loopj.com/jquery-tokeninput/