Buttons problem, not working with two tables (Uncaught InternalError: too much recursion)

Buttons problem, not working with two tables (Uncaught InternalError: too much recursion)

iamdevelopiamdevelop Posts: 6Questions: 0Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Uncaught InternalError: too much recursion
d https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:42
header https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:41
b https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:42
map jQuery
P https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:42
<anonymous> https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:39
e jQuery
S https://cdn.datatables.net/buttons/1.6.5/js/buttons.html5.min.js:16
action https://cdn.datatables.net/buttons/1.6.5/js/buttons.html5.min.js:22
g https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:14
l https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:15
jQuery 7
_buildButton https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:15
_expandButton https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:13
add https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:8
_constructor https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:11
w https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:7
H https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:6
jQuery 8
initDataTableBuscador http://develop.lanzaroteinvestments.com/lanza_crm/assets/js/admin.js?v=2237:1854
success http://develop.lanzaroteinvestments.com/lanza_crm/assets/js/admin.js?v=2237:806
jQuery 6
<anonymous> http://develop.lanzaroteinvestments.com/lanza_crm/assets/js/admin.js?v=2237:699
jQuery 8
<anonymous> http://develop.lanzaroteinvestments.com/lanza_crm/assets/js/admin.js?v=2237:199
jQuery 8
<anonymous> http://develop.lanzaroteinvestments.com/lanza_crm/assets/js/admin.js?v=2237:198
jQuery 11
dataTables.buttons.min.js:42:141
RegExpGlobalReplaceShortOpt self-hosted:3085
Symbol.replace self-hosted:2909
replace self-hosted:3863
d https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:42
header https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:41
b https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:42
map self-hosted:221
map jQuery
P https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:42
<anonymous> https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:39
e jQuery
S https://cdn.datatables.net/buttons/1.6.5/js/buttons.html5.min.js:16
action https://cdn.datatables.net/buttons/1.6.5/js/buttons.html5.min.js:22
g https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:14
l https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:15
jQuery 7
_buildButton https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:15
_expandButton https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:13
add https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:8
_constructor https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:11
w https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:7
H https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js:6
jQuery 8
initDataTableBuscador http://develop.lanzaroteinvestments.com/lanza_crm/assets/js/admin.js?v=2237:1854
success http://develop.lanzaroteinvestments.com/lanza_crm/assets/js/admin.js?v=2237:806
jQuery 6
<anonymous> http://develop.lanzaroteinvestments.com/lanza_crm/assets/js/admin.js?v=2237:699
jQuery 8
<anonymous> http://develop.lanzaroteinvestments.com/lanza_crm/assets/js/admin.js?v=2237:199
jQuery 8
<anonymous> http://develop.lanzaroteinvestments.com/lanza_crm/assets/js/admin.js?v=2237:198
jQuery 11
Description of problem:

Hello, im using datatables i a crm without a problem for a while.The thing is i have a page where you have a normal table that works, and then there is another table that gets build with an ajax request. After the table is append to the page and everything, then i initialize the new table and it seems ok but when i try any of the buttons i get the error Uncaught InternalError: too much recursion.

I did try to take out the other table thinking maybe that there were two tables was creating some problem but is not the case.

If anybody know what can be hapening ill be very grateful. Thx!

Replies

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765

    Do you have custom functions built with your buttons?

    Please post a link to your page or a test case replicating the issue so we can help debug. This is not a known issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • iamdevelopiamdevelop Posts: 6Questions: 0Answers: 0
    edited January 2021

    Thank you Kevin for your response, i will try to build something in the front end to test it, or maybe there is a way i can give you acces to check it.

    The buttons itself dont have anything special, the ones in the normal table works, its only the one that get built after and ajax succes, the two function are:

    The one that works..its called in "onready"

     function initDataTable() {
        var table = $('.myDatatable').DataTable( {
            dom: 'B<"clear">lfrtip',
            buttons: [ 'copy', 'csv', 'excel', 'pdf' ]
          });
    }
    

    The one that does not works..its called in a succes ajax call after append the html of the table in the page

     initDataTableBuscador(element)
        var table2 = $(''+element+' .tabla-resultado').DataTable( {
            dom: 'B<"clear">lfrtip',
            buttons: [ 'copy', 'csv', 'excel', 'pdf' ]
          });
    }
    

    Ill let you know if i can build something to can test it.

    Thx in advance for your time

    EDIT: Updated the Markdown backticks to be on separate lines.

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765

    Something doesn't look correct here:

    initDataTableBuscador(element)
        var table2 = $(''+element+' .tabla-resultado').DataTable( {
    

    Looks like you are missing the opening bracket ( { ) on the function line. You also have two '' here $(''+element. Should just be one. Surprised you aren't getting syntax errors.

    A problem like this needs to be seen to help diagnose where the issue is.

    Kevin

  • iamdevelopiamdevelop Posts: 6Questions: 0Answers: 0

    Well the opening bracket is just a mistake coping here the code, sorry

    The $(''+element etc is because the call that i do give the container of the table (initDataTableBuscador('.resultado-busqueda-contacto-2');)

    About been just one, i did try before but having like this actually does not give me any warning, i use this kind of call in other thing also with no problem so i would guess is not for that?

    if i try with the function without a variable element, still the same:

    function initDataTableBuscador(element) {
    
        var table2 = $('.quick-search-property .resultado-busqueda-comprador-quick-2 .tabla-resultado').DataTable({
            
            "pageLength": 100,
            dom: 'B<"clear">lfrtip',
            buttons: [
                'copy', 'csv', 'excel', 'pdf'
            ],
        });
    
        table2.buttons().container().insertBefore('.quick-search-property .resultado-busqueda-comprador-quick-2');
    
    }
    

    Ill try to build something in the front-end this way maybe you can check it, but it gonna take me a while =)

    Anyways, thank you for your time

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765

    Maybe you have something calling the function initDataTableBuscador multiple times. Have you investigated that piece of the code?

    Kevin

  • iamdevelopiamdevelop Posts: 6Questions: 0Answers: 0

    Good idea, i did not think about that.

    I just try to add a console.log to the function to see if its call more than one time but the log only show one time

    Thank you again =) ill let you know when i have something build

  • iamdevelopiamdevelop Posts: 6Questions: 0Answers: 0

    I found what was hapening, i had a colum that had a checkbox that cause the error.

    I dont know why.. but if anybody get this error try with this

    Thank you

  • vasilMirovvasilMirov Posts: 1Questions: 0Answers: 0

    @iamdevelop what was your solution? I am having a similar problem, I also have a Datatable that contains a checkbox and when I use the export button I get an InternalError: too much recursion. Did you remove the checkbox or used another way to represent the checkbox? Please explain your solution it will be of great help to me.

  • iamdevelopiamdevelop Posts: 6Questions: 0Answers: 0

    Hello @vasilMirov, sorry i didnt show your questions, in my case i had a <br> in the code that broke the buttons:

    html_properties += '<th style="text-align:center;">Select<br><input type="checkbox" class="ckeck-select-all" name="ckeck-select-all" value="0"" ></th>'; (incorrect)

    html_properties += '<th width="50px" style="text-align:center;">Select<input type="checkbox" class="ckeck-select-all" name="ckeck-select-all" value="0"></th>';(correct)

    I hope it heps somebody

Sign In or Register to comment.