选择视图并刷新页面时,DataTable不会加载,但仅在从导航中触发视图后才会加载。如何在页面刷新时加载视图,而不仅仅是触发?
this.get('#/campaigns/orders', function (context) {
this.partial('/Orders/');
$.ajax({
url: '/api/orders',
dataType: 'json',
success: function (data) {
var orders = $('#results').dataTable({
"bProcessing": true,
"sAjaxSource": '/api/orders',
"aoColumns": [
{ "mData": "Name" },
{ "mData": "Budget" },
{ "mData": "StartDate" },
{ "mData": "EndDate" },
{ "mData": "Status" },
{ "mData": "Created" },
{ "mData": "Changed"}
]
});
}
});
});
答案 0 :(得分:0)
this.get('#/campaigns/orders', function (context) {
this.partial('/Orders/');
$.ajax({
url: '/api/orders',
dataType: 'json',
success: function (data) {
$("document").on(load, function(){
var orders = $('#results').dataTable({
"bProcessing": true,
"sAjaxSource": '/api/orders',
"aoColumns": [
{ "mData": "Name" },
{ "mData": "Budget" },
{ "mData": "StartDate" },
{ "mData": "EndDate" },
{ "mData": "Status" },
{ "mData": "Created" },
{ "mData": "Changed"}
]
});
});
}
});
});
这未经过测试......这只是为了得到一个想法,
如果它不起作用,请尝试替换
$("document").on("load", function(){});
与
$("document").ready(function(){ });