Datatables within the ajax content

Datatables within the ajax content

olegasolegas Posts: 1Questions: 0Answers: 0
edited June 2010 in General
Hello
First want to say thanks for the great tool created :)

And now the question.
I have a table loaded with ajax (lavalamp menu)
[code]
$(document).ready(function(){

$('#admin_menu a').click(function() { //start function when any link is clicked
$(".content").slideUp("slow");
var content_show = $(this).attr("rel"); //retrieve rel of link so we can compare with php file
$.ajax({
type: "POST",
url: "<?php echo $this->config->item('base_url');?>index.php/admin/" + content_show,
success: function(html){ //so, if data is retrieved, store it in html
$(".content").show("slow"); //animation
$(".content").html(html); //show the html inside .content div
}
}); //close $.ajax(
}); //close click(
}); //close $(
[/code]

And it works good. I have one column with buttons when pressed it goes to the details for the record.
[code]
/* Click event handler */
$('#btnShowUserStats').live('click', function () {

/* Get the position of the current data from the node */
var row = this.parentNode.parentNode;
var cell = this.parentNode;
var aPos = oTable.fnGetPosition( cell );

/* Get the data array for this row */
var aData = oTable.fnGetData( row );

var id = aData[0];
console.log(id);
//$("#edit_user").dialog("destroy");

$.ajax({
type: "POST",
url: "<?php echo $this->config->item('base_url');?>index.php/admin/user_stats_view/" + id + "/" + $("#statsFrom").val() + "/" + $("#statsTo").val(),
success: function(html){ //so, if data is retrieved, store it in html
$(".content").empty();
$(".content").html(html); //show the html inside .content div

}
}); //close $.ajax(

return false;
} );// edituser click end
[/code]

Content is loaded on the top of existing content. And when it loads it does not displays the records and call fnInitComplete (however when I change the items per page it does).
Also I have few datepickers with Selected events, same thing works great on the first page, but in the final content it says oTable is undefined.

If I missed something while searching the forums and the problem was solved before, will be great to get the link to the thread.

Replies

  • EmekaEmeka Posts: 13Questions: 0Answers: 0
    I'm a noob so excuse me if I'm wrong, I don't see where datatables is initialized, assuming SlideUp is another way to do so should this line [code]$(".content").slideUp("slow")[/code] be:
    [code]oTable = $(".content").slideUp("slow")[/code] ?
This discussion has been closed.