【发布时间】:2015-11-17 23:19:56
【问题描述】:
以下代码设置表格:
gridSetup: function () {
var self = this;
$table = $('#csTable');
trows = $($table).find('tbody tr');
//0. IMPORTANT - clear table rows before re-building the table
trows.remove();
for (var x = 0; x < self.acYearCount; x++) {
var ay = x + 1;
//1. create a new row for each academic year
$tr = $('<tr class="cost-schedule ay' + [x + 1] + '"/>');
//2. create a new header
$th = $('<th class="horizontal">' + ay + '</th>');
//3. append header to row and row to table
$($table).append($($tr).append($th));
//4. add cells to current academic year row
for (var y = 0; y < 4; y++) {
$td = $('<td align="center"><input class="vertical" size="6" value="0"/></td>');
$($tr).append($td);
}
}
},
一个按钮运行这个:
editMe: function(){
$("#hideAll input").attr("disabled", false);
$("#hideAll select").attr("disabled", false);
这些函数在 vue.当我单击我的按钮时,我希望能够编辑创建的表。我尝试将 contenteditable="false" 放在 $td = $(''); 行中在 editMe 中使用 ("td").attr('contenteditable', true) 的网格设置。这些都不会使创建的表结构在按钮单击时可编辑。在上面的 editMe 中找到的行使创建的表上方的输入可编辑。感谢您的任何建议。
【问题讨论】:
-
你能告诉我们你的代码在 jsfiddle 上是什么吗?