Datatables within the ajax content
Datatables within the ajax content
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.
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.
This discussion has been closed.
Replies
[code]oTable = $(".content").slideUp("slow")[/code] ?