我的.gsp中有这段代码--通过jquery函数单击这个图像链接触发器事件。问题是,我希望将动态id (id="deleteSupp_${supplementary.id}" )传递给jquery函数,这样它就可以在单击图像链接时触发事件处理程序。
<div class="deleteSupplementary" data-supplementary=["${supplementary.id}","${supplementary.sth?.id}"]>
<a href="#" >
<r:img id="deleteSupp_${supplementary.id}" class="icon float-right" uri="/img/app-icon-delete.gif" title="delete"/>
</a>
</div>以下是jquery函数
function showConfirmationPanel(){
$("#deleteSupp_${supplementary.id}").live('click',function (event){
event.preventDefault();
$("#someform").show();
});
}发布于 2014-09-10 16:07:34
function showConfirmationPanel()
{
$('img[id^="deleteSupp_"').on
(
'click',
function (event)
{
event.preventDefault();
// Get the supplementary id
var sSuppId = $(this).closest(".deleteSupplementary")
.data("supplementary")[0];
$("#someform").show();
}
);
}https://stackoverflow.com/questions/25768201
复制相似问题