bootstraptable中onExpandRow屬性---js 方法添加的 html代碼,然后給這代碼里面的 元素 添加 事件,卻獲取不該元素。(稱之為未來元素),由於是未來的 所以現在沒有這個元素,導致獲取不到。
//代碼不會觸發點擊事件; //$("#btn_export_curr_page_detail").click(function () { // var attribute = $('#btn_export_curr_page_detail').attr('data-attribute6'); // AjaxRequest_CreateExcelFromCurrPageDetail(attribute); //});
onExpandRow: function (index, row, $detail) { var cur_table = $detail.html('<table id="report-query-detaillist-table"></table>').find('table'); var html = ""; html += '<div id="detailToolbar" class="btn-group">'; html += ' <button id="btn_export_curr_page_detail" data-attribute6 = "' + row.ATTRIBUTE6 + '" type="button" class="btn btn-default export-curr-page-detail">'; html += ' <span class="glyphicon glyphicon-export" aria-hidden="true"></span>@Html.LocText("ExportCurrentPage", "導出本頁到Excel")'; html += ' </button>'; html += ' <input type="hidden" id="txt_TotalRecordCount_Detail" />'; html += '</div>';
$("#report-query-baselist-table").on("click", '#detailToolbar .export-curr-page-detail', function () {
var attribute = $(this).attr('data-attribute6');
AjaxRequest_CreateExcelFromCurrPageDetail(attribute);
});
