我使用插件刷卡從列表中刪除行:爲什麼不將此方法附加到附加列表項?
$('#swipeMe li').swipeDelete();
$('#swipeMe li').on('click', function(){
$(this).trigger('swiperight')
});
的swipeDelete功能工作正常,當我用HTML寫:
<h2>Assets </h2>
<div id="Assets">
<ul id="swipeMe">
<li ><a href="#">This doesn't works</a></li>
<li data-swipeurl="#"><a href="#">This works<</a></li>
<li data-swipeurl="#"><a href="#">This works<</a></li>
<li data-swipeurl="#"><a href="#">This works<</a></li>
<li data-swipeurl="#"><a href="#">This works<</a></li>
<li data-swipeurl="#"><a href="#">This works<</a></li>
<li data-swipeurl="#"><a href="#">This works<</a></li>
<li >This doesn't</li>
</ul>
</div>
但它確實不是新名單我追加項目:
$('.submitAsset').click(function(){
var asset = $('#asset_number').val();
$('<li data-swipeurl="#"><a href="#">' + asset + '</a></li>')
.appendTo('#Assets #swipeMe').swipeDelete();
$('#assetForm').slideUp();
});
請幫助:/
您需要在生成HTML –