javascript - Passing dynamic element id to jquery function -
i've got code in .gsp image link trigger event on click through jquery function. problem want pass dynamic id (id="deletesupp_${supplementary.id}"
) jquery function can trigger event handler when image link clicked.
<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>
here jquery function
function showconfirmationpanel(){ $("#deletesupp_${supplementary.id}").live('click',function (event){ event.preventdefault(); $("#someform").show(); }); }
function showconfirmationpanel() { $('img[id^="deletesupp_"').on ( 'click', function (event) { event.preventdefault(); // supplementary id var ssuppid = $(this).closest(".deletesupplementary") .data("supplementary")[0]; $("#someform").show(); } ); }
Comments
Post a Comment