简体   繁体   English

JavaScript文件之间的冲突

[英]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 您好,我的专案中的JavaScript档案之间发生冲突,问题很明显,问题如下

In my admin panel all users are showing on a Bootstrap table where I can sort it. 在我的管理面板中,所有用户都显示在Bootstrap表上,可以对其进行排序。 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 我正在使用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');
                }
            });
        });

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. 或使用on代替live。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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