0

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');
                }
            });
        });
10
  • 1
    So, what exactly is the problem? When you do what, you see what? Are there errors in the debug console? Commented May 9, 2014 at 6:52
  • when i add this code to table the first page from table work correctly but other don't work Commented May 9, 2014 at 6:55
  • Did you get any error in console. Commented May 9, 2014 at 6:55
  • Do you know that .live() has been removed from recent versions of jQuery? Commented May 9, 2014 at 6:57
  • Did you call the script in all pages or make a script in separate page and to include the script file in all pages? Commented May 9, 2014 at 6:57

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.