zoukankan      html  css  js  c++  java
  • 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 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);
                    });
    

      

  • 相关阅读:
    iOS的文字自适应
    指向指针的指针
    NSString的创建
    Foundation-常用结构体
    Foundation summary
    成员变量补充
    Block^
    Protocol
    Category-分类
    李明杰要在广州开课啦
  • 原文地址:https://www.cnblogs.com/turnip/p/10834548.html
Copyright © 2011-2022 走看看