jquery - How To Reinitialize Datatable in Ajax -
what need
*when ajax loaded datable reintailized.
i explain in steps
- here output of first step :http://postimg.org/image/c6p8jwp3b/.
- here output of second step :http://postimg.org/image/6fm1z253h/
- here output of third step:http://postimg.org/image/5btny60xf/.
no reinitialize of datatable.
i want paging , search should reintialized.
i have taken url: http://datatables.net/forums/discussion/256/fnreloadajax/p1.
ajax call code:
if ($('#teamtable').size() > 0) { $('#teamtable').datatable({ "spaginationtype": "bootstrap" }); } $("#save_team").click(function() { $.ajax({ type: "post", url: "asana_team.php", data: { people_name: $('#e2').val(), team_name:$('#teamname').val() }, beforesend : function(){ $("#team_table").remove(); $("#team_table_div").append("<center id=\"loading\" style=\"margin-top:25%;margin-bottom:25%\"><img src='../common/images/ajax-loader.gif' /></center>"); }, contenttype: "application/x-www-form-urlencoded" }).done(function(data) { $("#loading").remove(); $('#team_table_div').append(data); $('#teamtable').datatable({ "spaginationtype": "bootstrap" }); }); });
* working fine reintializing pagination in datatable no datable loaded.
i have used code reinitailize table.
function callback() { var call= $('#teamtable'); call.datatable({ "spaginationtype": "bootstrap", "sdom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>", "olanguage": { "slengthmenu": "_menu_ records per page" } }); } $(document).ready(function() { callback(); });
destroy first using
$('#teamtable').datatable().fndestroy();
then reinitailize
$('#teamtable').datatable();
Comments
Post a Comment