1 回答
TA贡献1825条经验 获得超6个赞
尝试了另一种对我有用的方法。我想我可以在调用 ContextMenu 之前创建一个数组,并在函数本身中使用它,而不是使用“Build”。奇迹般有效。稍后将添加使用表刷新代理列表。
// Call the dataTables jQuery plugin - SQL Server Wachtrij view.
$(document).ready(function() {
var table = $('#dataTable').dataTable(
{
"bPaginate": false,
"bFilter": false,
"bInfo": false,
"bProcessing": false,
"sAjaxSource": "wachtrij.php",
"aoColumns": [
{ mData: 'callcenter' } ,
{ mData: 'Tijdstip_binnengekomen' },
{ mData: 'Wachttijd'},
{ mData: 'telefoonnummer'},
{ mData: 'Wachtrij_Positie'},
{ mData: 'callid'}
],
})
// Make sure dataTable refreshes every 5 seconds
setInterval( function () {
table.api().ajax.reload();
}, 5000 );
$(function(){
// Get agentdata from server
var request = new XMLHttpRequest()
request.open('GET', 'ActiveList.php', true)
request.onload = function() {
var data = JSON.parse(this.response)
// create array from http call
var menuitems = [];
$.each(data, function( key, value ) {
menuitems[key] = { name: value.agent, icon: "checkmark", onclick: function () {
RToTb(array_name) }};
});
//create the contextmenu using the array as menuitems
$.contextMenu({
selector: '#dataTable td',
trigger: 'left',
items: menuitems
});
}
//Send the request
request.send()
});
});
- 1 回答
- 0 关注
- 129 浏览
添加回答
举报