bootstrap table 生成的表格里动态添加HTML元素按钮,JS中添加点击事件,点击没反应---解决办法
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 >); var html = ""; html += '<div >; html += ' <button >; html += ' <span class="glyphicon glyphicon-export" aria-hidden="true"></span>@Html.LocText("ExportCurrentPage", "导出本页到Excel")'; html += ' </button>'; html += ' <input type="hidden" >; html += '</div>';
$("#report-query-baselist-table").on("click", '#detailToolbar .export-curr-page-detail', function () { var attribute = $(this).attr('data-attribute6'); AjaxRequest_CreateExcelFromCurrPageDetail(attribute); });