I have a number of serverside generated HyperLinks
<a id="ctl00_ContentPlaceHolder1_APMySlides_unlinkImage_2428_1" title="Click Here to remove this image from this application." class="APMySlides_unlinkImage" href="#"></a>
<a id="ctl00_ContentPlaceHolder1_APMySlides_unlinkImage_2428_2" title="Click Here to remove this image from this application." class="APMySlides_unlinkImage" href="#"></a>
<a id="ctl00_ContentPlaceHolder1_APMySlides_unlinkImage_2428_3" title="Click Here to remove this image from this application." class="APMySlides_unlinkImage" href="#"></a>
<a id="ctl00_ContentPlaceHolder1_APMySlides_unlinkImage_2424_3" title="Click Here to remove this image from this application." class="APMySlides_unlinkImage" href="#"></a>
A section to trigger the update
<asp:HiddenField ID="delhiddenfield" runat="server" />
<asp:Button ID="lauchdelete" runat="server" Text="" OnClick="removeLink" CssClass="lauchdelete" style="display:none;" />
<div id="deleteconfirm" title="Are you sure?" style="display:none;">Are you sure you want to remove this image from this application?</div>
A tiny bit of JQuery which call another function when any are clicked
var del = '<%=delhiddenfield.ClientID %>';
$(function(){
$('.APMySlides_unlinkImage').click(function (event) { triggerdel(event); });
});
function triggerdel(event) {
var caller = event.target || event.srcElement;
// get the id vals
var idsplit = caller.id.split("_");
if (idsplit.length > 2) {
$('#' + del).val(idsplit[idsplit.length - 2] + "_" + idsplit[idsplit.length - 1]);
$("#deleteconfirm").dialog({
resizable: false,
height: 140,
modal: true,
buttons: {
"Delete": function () {
// this section is supposed to trigger the update
$('.lauchdelete').click();
$('#' + del).val('');
},
Cancel: function () {
$(this).dialog("close");
}
}
});
}
}
If I put a OnClientClick="alert('woo lauchdelete clicked')" into the launchdelete button it does trigger but my code behind does not call. However if I take out the modal dialog like so:
function triggerdel(event) {
var caller = event.target || event.srcElement;
// get the id vals
var idsplit = caller.id.split("_");
if (idsplit.length > 2) {
$('#' + del).val(idsplit[idsplit.length - 2] + "_" + idsplit[idsplit.length - 1]);
$('.lauchdelete').click();
$('#' + del).val('');
}
}
The code functions correctly, and triggers the code behind. The only difference I can see is the dialog control, but why? Is there any way to get the control to trigger as expected, with the modal dialog delete button being pressed?