Cell click problem
Cell click problem
Hi, First of all this is an amazing plugin and it's been great working with it, but I have just come into a problem that has left me scratching my head.
I need to be able to click a cell of the table and depending on which cell is clicked, a different modal will appear. However, the code I have been using will only work on the first row, even when pagination is turned off.
An example of my code:
[code]
$('#detailsTable tbody tr td:eq(3)').live('click', function(){
var data = oTable.fnGetData(this);
$("#modalHeader").append("Shipping Information");
$("#modalBody").append("From our records, it seems that " + data + " item from the quantity that you have ordered have left our stores and are currently on the way to you.");
$("#modal-window").modal('show');
});
[/code]
I have tried using delegate and also on but I can only get it to even come close to working when using live.
Any help or suggestions are greatly appreciated
I need to be able to click a cell of the table and depending on which cell is clicked, a different modal will appear. However, the code I have been using will only work on the first row, even when pagination is turned off.
An example of my code:
[code]
$('#detailsTable tbody tr td:eq(3)').live('click', function(){
var data = oTable.fnGetData(this);
$("#modalHeader").append("Shipping Information");
$("#modalBody").append("From our records, it seems that " + data + " item from the quantity that you have ordered have left our stores and are currently on the way to you.");
$("#modal-window").modal('show');
});
[/code]
I have tried using delegate and also on but I can only get it to even come close to working when using live.
Any help or suggestions are greatly appreciated
This discussion has been closed.
Replies
There are a few ways of doing it in jQuery:
[code]
$('#detailsTable tbody tr').find('td:eq(3)')...
[/code]
or perhaps better for a live event handler:
[code]
$('#detailsTable tbody tr>td:nth-child(3)')...
[/code]
Allan
Note that I've used jQuery 1.7's `on` rather than `live` as `live` is deprecated.
Allan