我正在尝试使用js和jquery动态创建表。该表可以正常工作,但是第一列是一个链接的弹出窗口,该弹出窗口在相应的行中显示信息图。当我对表进行硬编码时,“图形”按钮确实会启动弹出窗口。但是,当我动态创建表时,弹出窗口不会启动-一切正常,除了图形显示在同一选项卡中。 这是调用弹出窗口的功能
$(document).ready(function() {
$('form').submit(function() {
window.open('', 'popup',
'width=1100,height=500,resizeable,scrollbars');
this.target = 'popup';
});
});
// this is the dynamically created table
function get_table() {
$.getJSON('/_ajax_candidates', function(data) {
$('#date').text(data.cur_date)
$('#graphTable tbody').remove();
for (let j = 0; j < data.df.length; j++) {
let formText = "<form action='/popwindow' method='post'>" +
"<input type='hidden' id='pone' name='port_one'
value = " + encodeURIComponent(data.df[j]['port_one']) + " > " +
"<input type='hidden' id='ptwo' name='port_two'
value = " + encodeURIComponent(data.df[j]['port_two']) + " > " +
"<input type='submit' value='Graph' > </form>"
var row = document.getElementById('bodyStart').insertRow(j);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
var cell5 = row.insertCell(4);
var cell6 = row.insertCell(5);
var cell7 = row.insertCell(6);
var cell8 = row.insertCell(7);
var cell9 = row.insertCell(8);
var cell10 = row.insertCell(9);
var cell11 = row.insertCell(10);
var cell12 = row.insertCell(11);
var cell13 = row.insertCell(12);
cell1.innerHTML = formText;
cell2.innerHTML = data.df[j]['port_one'];
cell3.innerHTML = data.df[j]['port_two'];
cell4.innerHTML = data.df[j]['pval'];
cell5.innerHTML = data.df[j]['beta'];
cell6.innerHTML = data.df[j]['std'];
cell7.innerHTML = data.df[j]['zscore_y'];
cell8.innerHTML = data.df[j]['zscore'];
cell9.innerHTML = data.df[j]['zscore_20dy'];
cell.innerHTML = data.df[j]['zscore_20d'];
cell11.innerHTML = data.df[j]['std_20d'];
cell12.innerHTML = data.df[j]['mean_20d'];
cell13.innerHTML = data.df[j]['cur_val'];
}
});
};
当我单击表格中的“图形按钮”时,当前窗口将替换为图形,而不是在弹出窗口中生成。
感谢您的帮助。我一直都在拖曳stackoverflow,但之前从未问过这个问题。
预先感谢