0

在 jQuery 中,我如何加载生成的 HTML 并对它进行一些操作?

首先:从另一个页面加载我的 HTML:

$.post("my_page.php?operation=show_data&session=<?php echo SESSION_UUID;?>", 
        function(data){
            $("#data-table").empty().append();
        }
    );

现在,我不能执行以下操作:

//the .preview-table is in the appended HTML
$(".preview-table").dataTable( {}); // this is a plugin jQuery plugin

是的,我读过我可以使用 .live() 但它只适用于事件......

如何将插件正确加载到选择器?

数据表插件:http ://datatables.net/

4

1 回答 1

3
$.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);
        }
    );
于 2012-08-19T07:09:58.090 回答