以下代码包含构建表格的扩展详细信息(子行)的所有详细信息。 (实际上有2个,只显示1我遇到问题)。
当我展开一行时,我会使用一些按钮来执行各种功能。这些按钮,至少有一些,似乎正在执行3次。
当需要对某些用户操作使用确认时,我注意到了这个问题。我注意到我得到了3次动作的确认。我一直无法找到原因。
按钮使用动态命名约定,因此每行都有一个唯一的名称。它们是在展开行时创建的。有问题的2个项目列在子弹中,因为它们可以更容易找到(我还没有实现第3个,但我有信心,如果我能解决其中一个,它将导致我修复所有这些);
重新编号_
function compExtInfo($detail, row) {
pID = row.ID;
$detail.append('<div id="exttoolbar2_'+pID+'">');
$detail.append('<button id="addext_'+pID+'" class="btn btn-primary"> Add Row </button>');
$detail.append('<button id="editext2_'+pID+'" class="btn btn-success"> Edit Row </button>');
$detail.append('<button id="delext_'+pID+'" class="btn btn-info"> Delete Row </button>');
$detail.append('<button id="renumber_'+pID+'" class="btn btn-warning"> Auto Renumber Days </button>');
$detail.append('<button id="finalize_'+pID+'" class="btn btn-danger"> Finalize 90 Day Report </button>');
$detail.append('</div>');
buildTable2($detail.append('<table id="exttable2_'+pID+'"></table>').find('table'), pID);
}
function buildTable2($ext, ID) {
$ext.bootstrapTable({
url: 'get90dayinfo.php?ID='+ID+'&d='+$.now(),
uniqueId: 'ID',
clickToSelect: true,
toolbar: '#exttoolbar_'+ID,
columns: [
...
],
onLoadSuccess: function(row, index){
$('#addext_'+ID).click(function(){
$('#message').collapse('hide');
var gAPI = $.map($ext.bootstrapTable('getSelections'), function (row) {
$('#addID90').val(row.ID);
$('#addtable2').val('exttable2_'+row.ID);
//get the next day to populate
var gDay = $.get( 'get90maxday.php?ID='+ID+'&d='+$.now(), function(data) {
$('#addday').val(data);
});
$('#add90modal').modal();
});
return row.id;
});
$('#delext_'+ID).click(function(){
var pTmp = $.map($ext.bootstrapTable('getSelections'), function (row) {
$('#message').collapse('hide');
pID = row.ID;
pDay = row.day;
pDate = row.date;
if (confirm('This will delete day '+pDay+' date '+pDate)){
$.get( '90deldata.php?ID='+pID+'&day='+pDay+'&d='+$.now(), function( data ) {
if(data=='success'){
$('#message p').text('Day '+pDay+' Date '+pDate+' successfully deleted');
$('#message').collapse('show');
$ext.bootstrapTable('refresh');
$().abort;
}
});
}
});
});
$('#editext2_'+ID).click(function(){
$('#message').collapse('hide');
var gAPI = $.map($ext.bootstrapTable('getSelections'), function (row) {
$('#editext90modal').modal();
});
return row.id;
});
$('#renumber_'+ID).click(function(){
$('#message').collapse('hide');
$ext.bootstrapTable('checkAll');
$('#renumber_'+ID).unbind('click');
var pID = $.map($('#90day').bootstrapTable('getSelections'), function (row) {
return row.ID;
});
$('#message').collapse('hide');
pID = row.ID;
var updatedWell = $.map($('#90day').bootstrapTable('getSelections'), function (row) {
return row.well_name+' '+row.well_num+' API '+row.api;
});
if (confirm('Are you sure you want to re-order '+updatedWell)){
$.get('90dayrenumber.php?ID='+pID+'&d='+$.now(), function(data) {
if(data=='success'){
$('#message p').text(updatedWell+' successfully re-ordered');
$('#message').collapse('show');
$ext.bootstrapTable('refresh');
}
});
}
});
}
});
}