Reputation: 8962
in jQuery, how do i load an generated HTML and do some manipulation to it?
First: load my HTML from another page:
$.post("my_page.php?operation=show_data&session=<?php echo SESSION_UUID;?>",
function(data){
$("#data-table").empty().append();
}
);
now, i can't do the following:
//the .preview-table is in the appended HTML
$(".preview-table").dataTable( {}); // this is a plugin jQuery plugin
and yes i've read that i can use .live() but then it works on events only...
how do i load the plugin to the selector properly?
DataTable plugin: http://datatables.net/
Upvotes: 0
Views: 74
Reputation: 342635
$.post("my_page.php?operation=show_data&session=<?php echo SESSION_UUID;?>",
function(data){
$("#data-table").empty().append(data);
// now that the elements have been replaced,
// re-initialise plugin
$(".preview-table").dataTable(options);
}
);
Upvotes: 3