Getting onClick event on link inside the table

Getting onClick event on link inside the table

cloonerclooner Posts: 7Questions: 0Answers: 0
edited May 2011 in General
I'm trying to attach a function to the Click event on a link in a cell. It's a delete button. I want it to ask the user to ask the question if it is ok to delete the row.

With fnRender I alter the data so a delete icon will appear.
[code]
"fnRender": function ( oObj ) { return ''; }
[/code]

With jquery I try to attach the function to confirm like so
[code]
$(".deleteMyRow").click(function() {
var str = $(this).attr('title');
var answer = confirm(str + " ,weet u het zeker?");
if (!answer) return false;
});
[/code]

Obviously since I use server side processing data the click function never gets attached to the link.

My question is, how or in which function of the datatable do I put the jquery click event handler? I searched the documentation but somehow I couldn't find it or I overlooked it. This should be a pretty common thing but I can't seem to find it in the docs.

Kind regards,

Jeroen

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    It is quite a common thing, and it's in the FAQs: http://datatables.net/faqs#ss_events :-) . I'd suggest just using a live event rather than $().click() for this, since it will be much easier to maintain.

    Allan
This discussion has been closed.