简体   繁体   中英

conflict between JavaScript files

Hello i have a problem in the conflict between the JavaScript files in the my project clearly the problem is as follows

In my admin panel all users are showing on a Bootstrap table where I can sort it. There are also a pagination system. Looks Good.

I want a system => Make the full row as a button and after click on the row it's should be show a collapse hidden information "bellow the each row" where I will put users information.

i'm using sb admin v2 link and this code will add to table file

$(document).ready(function() {

            /*
             * Initialse DataTables, with no sorting on the 'details' column
             */
            var oTable = $('#example').dataTable({
                "aoColumnDefs" : [{
                    "bSortable" : false,
                    "aTargets" : [0]
                }],
                "aaSorting" : [[1, 'asc']]
            });
            $('#example tbody td ').live('click', function() {
                var nTr = $(this).parents('tr')[0];
                if (oTable.fnIsOpen(nTr)) {
                    /* This row is already open - close it */
                    this.src = "../examples_support/details_open.png";
                    oTable.fnClose(nTr);
                } else {
                    /* Open this row */
                    this.src = "../examples_support/details_close.png";
                    oTable.fnOpen(nTr, fnFormatDetails(oTable, nTr), 'details');
                }
            });
        });

You put the below code in every datatable called in pages.

$('#example tbody td ').live('click', function() {
                var nTr = $(this).parents('tr')[0];
                if (oTable.fnIsOpen(nTr)) {
                    /* This row is already open - close it */
                    this.src = "../examples_support/details_open.png";
                    oTable.fnClose(nTr);
                } else {
                    /* Open this row */
                    this.src = "../examples_support/details_close.png";
                    oTable.fnOpen(nTr, fnFormatDetails(oTable, nTr), 'details');
                }
            });

For Ex:

<table id="example">
<tr>
<td></td>
</tr>
</table>
<script>
 $('#example tbody td ').live('click', function() {
                    var nTr = $(this).parents('tr')[0];
                    if (oTable.fnIsOpen(nTr)) {
                        /* This row is already open - close it */
                        this.src = "../examples_support/details_open.png";
                        oTable.fnClose(nTr);
                    } else {
                        /* Open this row */
                        this.src = "../examples_support/details_close.png";
                        oTable.fnOpen(nTr, fnFormatDetails(oTable, nTr), 'details');
                    }
                });
</script> 

or using on instead of live.

Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM