0
我已经创建了添加表格行的代码,并尝试将第三方SuggestBox函数绑定到每个动态生成的表单字段。如何绑定和取消绑定第三方jQuery库函数?
<script type="text/javascript">
$(document).ready(function() {
$('#form1').validationEngine();
var newRowNum = 1;
$(".addRow").click(function(){
var $newTr = $("#tb1 tbody>tr:last").clone(true);
$newTr.find('input[id^=foods]').unbind(jsonSuggest()); <== try to unbind the previouse jsonsuggest()
//$newTr.find('.jsonSuggestResults').remove();
$newTr.appendTo("#tb1 tbody");
$('input[id^=foods]', $newTr).val('');
$newTr.find('input[id^=foods]').each(function(){
$(this).jsonSuggest(
function(text, wildCard, caseSensitive, notCharacter) {
rez = $.ajax({
type: 'GET',
url: 'getFoodJSON.jsp',
data: 'foods=' + text,
dataType: 'json',
async: false
});
return eval(rez.responseText);
},
{ ajaxResults:true
});
});
$newTr.find('input[id^=supplyDate]').each('id', function(){
$(this).datepicker({dateFormat:'yy-mm-dd'});
});
});
});
然而,SuggestBox建议积累重复。下面是结果,当我输入的东西在7行...
你介意告诉我如何解除绑定的前一行+表单字段应用的功能?谢谢。