jquery - Make Datatables row clickable -


i have table loaded data via ajax using datatables.net. i'd make when user clicks on row links url appended variable of row's primary key.

i'm rather new datatables hacked attempt/idea use datatables apply 2 classes 2 column primary key. 2 classes hide (css of display:none) , projectid (identifying column can grab it's value jquery). able apply classes using aocolumns property , did hide column , append projectid class well. think since datatables creating table it's preventing me using

$('#project-table tr').click(function(){alert('clicked');} 

so tried

$('#project-table tr').live('click',function(){alert('clicked');})}; 

also no avail.

i imagine there better way i'm using make row clickable, linking page appended primary key variable, couldn't find example. if has link example or point me in right direction it'd appreciated.

i have table loaded data via ajax using datatables.net

that means event handlers bound elements during page load not applicable loaded data unless event delegated static parent element -- meaning element never removed or replaced, , exist indefinitely.

$(document).on('click', '#project-table tr', function(){     alert('this click on dynamic element'); }); 

here, we've bound click event document. can choose element closer (for performance increases) if choose.

here link documentation .on()

as side note -- in jquery 1.9 +, few functions have been removed. 1 of them .live() function, has been replaced .on() method (as displayed above). why didn't work. also, console tell this. many current browsers come own web inspector, otherwise can google search browser , find alternative.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -