我有以下jTemplate:
{#foreach $T.d as post}
<li>
<label for="ContactDetail">{$T.post.DetailType}</label>
<input type="text" id="ContactDetail_{$T.post.ContactDetailId}" runat="server" class="w400" autocomplete="on" value='{$T.post.Detail}' />
<div id="deletecontactdeet"><a href="#" id='{$T.post.ContactDetailId}' class='delete-deet'><img src="/images/iconography/tiny-delete.png" alt="Delete this entry" title="Delete this entry" border="0" /></a></div>
</li>
{#/for}然后,我将调用此模板,将.click附加到模板中的a:
var deetid;
$('.delete-deet').click(function () {
deetid = $(this).attr('id');
alert(deetid);
$('#delete-dialog').dialog('open');
return false;
});然而,.click从不触发。我怀疑这可能是因为DOM对象是/已经在模板中创建的-有人有任何关于如何解决这个问题的线索或建议吗?
我们将一如既往地感谢您的帮助。
发布于 2011-08-15 22:24:31
试试.live()
$('.delete-deet').live('click', function () {
deetid = $(this).attr('id');
alert(deetid);
$('#delete-dialog').dialog('open');
return false;
});https://stackoverflow.com/questions/7065962
复制相似问题