簡體   English   中英

JavaScript文件之間的沖突

[英]conflict between JavaScript files

您好,我的專案中的JavaScript檔案之間發生沖突,問題很明顯,問題如下

在我的管理面板中,所有用戶都顯示在Bootstrap表上,可以對其進行排序。 還有一個分頁系統。 看起來不錯。

我想要一個系統=>將整個行作為按鈕,單擊該行后,應該顯示折疊的隱藏信息“將每一行圍住”,我將在其中放置用戶信息。

我正在使用sb admin v2 鏈接 ,此代碼將添加到表文件中

$(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');
                }
            });
        });

您將以下代碼放在頁面中調用的每個數據表中。

$('#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');
                }
            });

例如:

<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> 

或使用on代替live。

謝謝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM