how to put java event onclick
how to put java event onclick
I just can't figure out where do i put onclick event on each data row. I would like to make a simple alert when click on each row.
for example when i use ordinary html table i can use onclick on each tr like this
[code]test[/code]
in datatables how do i achieve this.
please help
Thanks to all
for example when i use ordinary html table i can use onclick on each tr like this
[code]test[/code]
in datatables how do i achieve this.
please help
Thanks to all
This discussion has been closed.
Replies
example:
[code]
$('#oTable tbody tr').live('click', function () {
//your function here
}
[/code]
[code]
$('#divContainingMyTable').delegate('tbody tr', 'click', function() {
//your function here
}
[/code]
If #divContainingMyTable is something that is ever-changing, you could do something more dynamic using .closest() and .parent() to traverse the DOM looking for an appropriate element to attach the listener to.
Note on using .delegate: I don't understand the technical implications of how the two methods handle bubbling differently, but I'm taking people's word for it that .delegate() is a more efficient jQuery method than .live(). If I'm being honest, I don't see any real reason to not just do it mirkec's way unless it is a design priority to meticulously squeeze every drop of performance out of your application. I present it here only as an option with no real evidence that it's better.
Short version: switching from .click() in fnRowCallback to .delegate() has not solved my memory leak. Not sure which thread that news is better off in. ;-)
i got it to work by using .live as mirkec advise. thank u.
then I shall try GregP's way to see what's different.
thanks to all again.
you guys are so cool.