表单 – 在Ajax成功时刷新数据表
发布时间:2020-12-26 01:42:44 所属栏目:资源 来源:网络整理
导读:副标题#e# 我正在使用datatables和 jquery对话框.总的来说,我有3个表格和3个数据表. 我的脚本工作得很好,但我正在努力的事情就是在ajax save成功时更新正确的数据表(它甚至不必是正确的相应表,它可以更新3个表单保存中的任何3个表. ) 任何指导将不胜感激.
编辑 – 只显示正确的表格,您可以执行以下操作: function dialogForms() { $('a.menubutton').click(function() { var id = this.id;// Save the id of the clicked button var a = $(this); $.get(a.attr('href'),buttons: { 'Save': function() { submitFormWithAjax($(this).find('form'),id);// Pass the id to the function function submitFormWithAjax(form,id) { form = $(form); var table_id; // Choose the table to display depending on the id,i made some guesses but adjust this switch(id){ case 'view_academic': table_id = '#academic_table'; break; case 'view_business': table_id = '#business_table'; break; case 'line_managers': table_id = '#line_managers_list'; break; } $.ajax({ url: form.attr('action'),success: function(data){ $(this).dialog('close'); // Refresh table var oTableToUpdate = $(table_id).dataTable( { bRetrieve : true } ); $oTableToUpdate .fnDraw(); // Hide all tables $('table').hide(); // Show the refreshed $(table_id).show(); } }); return false; } (编辑:南平站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |