fnOpen not working
fnOpen not working
JustinTime
Posts: 4Questions: 0Answers: 0
Sorry for the second question in as many days, but can't seem to figure this one out either. >_<
Ok, so I have a table, and one of the TDs in each TR displays a preview of a description. In the TD is a span with the text "Show". I want to let the user click this text and then pop a new row immediately after the row this span & TD are in to display the full description.
[code]
//Example of span nesting
description preview...Show
[/code]
The fnOpen documentation shows the click-event listener on the TR being placed immediately before the table is made a DataTable, so I also put my code just before my DataTable's initialization. However, the click-event listener is being placed on the TR in the documentation. Is this necessary? I want to have the user click the span inside the TD, not anywhere on the TR. However, trying something like this does not work:
[code]
$('.desc_toggle').live('click', function() {
var desc = "test desc";
table.fnOpen($(this).parent().parent(), desc, 'full_desc');
alert('after');
});
table = $('#table_id').dataTable({initialization});
[/code]
If I alert $(this).parent().parent().html() before trying to use fnOpen, I get all the HTML within the TR, which seems to confirm that I am selecting the TR that i want. Additionally, the alert('after') runs fine, so I know it's not getting hung up on the fnOpen. And I don't see any JS errors using Firebug and Web Developer Toolbar in Firefox 4.
Any ideas? Does fnOpen support this kind of selection within the function? I've tried also saving $(this).parent().parent() in a variable and passing that variable as the first argument into fnOpen, but that changes nothing.
Thanks in advance,
Justin
P.S. Using DataTables 1.7.6
Ok, so I have a table, and one of the TDs in each TR displays a preview of a description. In the TD is a span with the text "Show". I want to let the user click this text and then pop a new row immediately after the row this span & TD are in to display the full description.
[code]
//Example of span nesting
description preview...Show
[/code]
The fnOpen documentation shows the click-event listener on the TR being placed immediately before the table is made a DataTable, so I also put my code just before my DataTable's initialization. However, the click-event listener is being placed on the TR in the documentation. Is this necessary? I want to have the user click the span inside the TD, not anywhere on the TR. However, trying something like this does not work:
[code]
$('.desc_toggle').live('click', function() {
var desc = "test desc";
table.fnOpen($(this).parent().parent(), desc, 'full_desc');
alert('after');
});
table = $('#table_id').dataTable({initialization});
[/code]
If I alert $(this).parent().parent().html() before trying to use fnOpen, I get all the HTML within the TR, which seems to confirm that I am selecting the TR that i want. Additionally, the alert('after') runs fine, so I know it's not getting hung up on the fnOpen. And I don't see any JS errors using Firebug and Web Developer Toolbar in Firefox 4.
Any ideas? Does fnOpen support this kind of selection within the function? I've tried also saving $(this).parent().parent() in a variable and passing that variable as the first argument into fnOpen, but that changes nothing.
Thanks in advance,
Justin
P.S. Using DataTables 1.7.6
This discussion has been closed.
Replies
For some reason, you can't use fnOpen with an jQuery object so using $(this) is not going to work; instead you've got to do it the long way...
[code]
$('.desc_toggle').live('click', function(){
var td = this.parentNode;
var tr = td.parentNode;
table.fnOpen(tr, 'data', 'class_to_use');
}
[/code]
[code]
$(this).parents('tr')[0]
[/code]
:-)
Allan