我有一个引导 javascript 表,当前在文档准备好时加载,如下所示:
$(document).ready(function(){
$('#table-javascript').bootstrapTable({
method: 'get',
url: 'bootstrap_database.php',
height: 600,
cache: false,
striped: true,
pagination: true,
search: true,
pageSize: 20,
pageList: [20, 40, 60, 100, 200],
minimumCountColumns: 2,
clickToSelect: true,
columns: [{
field: 'ID',
title: 'ID',
align: 'center',
visible: false
},{
field: 'title',
title: 'Title',
align: 'center',
sortable: true,
width: '20'
},{
field: 'audio',
title: 'Audio',
align: 'center',
width: '20'
},{
field: 'sheet1',
title: 'Sheet 1',
align: 'center',
width: '20'
},{
field: 'sheet2',
title: 'Sheet 2',
align: 'center',
width: '20'
},{
field: 'sheet3',
title: 'Sheet 3',
align: 'center',
width: '20'
},{
field: 'lyrics',
title: 'Lyrics',
align: 'center',
width: '20'
},{
field: 'sheet1notes',
title: 'Notes 1',
align: 'center',
width: '20'
},{
field: 'sheet2notes',
title: 'Notes 2',
align: 'center',
width: '20'
},{
field: 'sheet3notes',
title: 'Notes 3',
align: 'center',
width: '20'
}],
aoColumnDefs: [{
bSearchable: false,
bVisible: true,
aTargets: [0]
}]
});
});
我想在页面的其他部分重新加载表格。我的想法是有几个可以触发此功能的处理程序。也许一个.click()
或.change()
会这样做。但我不确定是否可以让多个处理程序触发同一个函数。
这是一个 ajax 调用示例,我想在 a 之后刷新表success
:
$( "#addnewsong" ).on( "submit", function( event ) {
$('.newsongupprog').replaceWith('<i class="fa fa-spin fa-spinner"></i>');
thisdata = new FormData($("#addnewsong")[0]);
$.ajax({
url: "multiple_upload_ac.php?",
data: thisdata,
type : "post",
cache: false,
contentType: false,
processData: false,
success: function(data){
$('.fa-spinner').replaceWith('<i class="fa fa-check"></i>');
$('.fa-check').replaceWith('<i class="fa fa-cloud-upload"></i>');
if (data == 'go') {
data = "Your song has been uploaded";
} else {
data = "There was a problem uploading some of your files, please search for your song title and add your files manually";
}
$('div.alert3').fadeIn();
$('div.alert3').html(data);
$('div.alert3').delay(5000).fadeOut();
$table.bootstrapTable('refresh', {
url: 'bootstrap_database.php'
});
},
});
return false;
});
我觉得我的方法很遥远,所以我能否请一些专家对此有所了解。