Adding row then delete that same row: Maximum call stack size exceeded

Adding row then delete that same row: Maximum call stack size exceeded

fifofifo Posts: 2Questions: 1Answers: 0

So everything works perfectly, except when using the editor if I insert a new row then select and delete that row I always get Uncaught RangeError: Maximum call stack size exceeded (and lots of: n.extend.n.fn.extend recursive calls).

If I refresh the page after inserting there is no problem, I can delete/edit/etc. at will. Just if I insert a new row and then without refreshing proceed to try and delete it, that popup "Are you sure?" freezes with the errors popping up in the console.

The back-end of this inserts a new row into the database with an auto-incrementing ID. I'm wondering if this has something to do with the issue (inserting a new row with a blank ID). I see when the new row is inserted the ID shows up accurately in it's column, but when I look at the "onsubmit" of the new row insertion, the json data ID is null.

Any help anyone can provide on this is much appreciated!

The code is for a client so I can't show it here, however I could modify it if necessary and post.

Answers

  • allanallan Posts: 63,461Questions: 1Answers: 10,466 Site admin

    If you could modify it and then link to the page showing the issue, that would let me trace through it and help to debug. I've not encountered that issue before.

    What is the server-side responding with when you create a new row? Can you show me that JSON? Does it include the newly created ID (it should be blank, presumably the database will set it on INSERT).

    Allan

  • fifofifo Posts: 2Questions: 1Answers: 0
    edited December 2017

    Hi Allan, I'm currently running it on localhost through an ngrok tunnel so I'd prefer to not share, but can PM a temp link if needed.

    Hopefully this will help clarify though.

    When inserting a new row the data is inserted into the database with a null ID which autoincrements in the DB. After insertion, another query calls the last inserted row and gets the ID which is added to the json that's returned, here's the raw dict that's returned (before being converted to json):

    {
        'id': 5882,
        'company_name': 'Another test store',
        'address': '',
        'address_2': '',
        'phone': '',
        'fax': '',
        'email': '',
        'city': '',
        'all_states': '',
        'main_state': '',
        'state': '',
        'state_2': '',
        'state_3': '',
        'state_4': '',
        'website': '',
        'zip': 0,
        'google_map_link': '',
        'longitude': 0,
        'latitude': 0,
        'product_installation': '',
        'samples_for_show': 'No',
        'samples_for_taking': 'No',
        'user_Type': '',
        'status': 'Active',
        'created_by': 0,
        'dealer': 0,
        'distributor': 0
    }
    

    That is just directly converted to json, so "onsubmit" had to add the proper "data" wrapper, and that code looks like so:

    editor.on('postSubmit', function( e, json, data, action ) {
             console.log(action, data, json);
                 json.data = [json];
        });
    

    That console.log you see above spits out this data:

    data
    :
    0
    :
    address
    :
    ""
    address_2
    :
    ""
    all_states
    :
    ""
    city
    :
    ""
    company_name
    :
    "Another test store"
    created_by
    :
    "0"
    dealer
    :
    "0"
    distributor
    :
    "0"
    email
    :
    ""
    fax
    :
    ""
    google_map_link
    :
    ""
    id
    :
    null
    latitude
    :
    "0"
    longitude
    :
    "0"
    main_state
    :
    ""
    phone
    :
    ""
    product_installation
    :
    ""
    samples_for_show
    :
    "No"
    samples_for_taking
    :
    "No"
    state
    :
    ""
    state_2
    :
    ""
    state_3
    :
    ""
    state_4
    :
    ""
    status
    :
    "Active"
    user_Type
    :
    ""
    website
    :
    ""
    zip
    :
    "0"
    

    So after hitting "Create" on the Editor popup the row is inserted into the table and all data in that new table row is accurate to what had been entered in the Editor popup (including the ID), if I refresh the page everything works perfectly with no problems. It's only if I happen to delete that freshly created row without refreshing first that the problem occurs.

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • allanallan Posts: 63,461Questions: 1Answers: 10,466 Site admin

    That does look like it should work okay. If you could PM me the link, that would be awesome. You can send me a PM by clicking my forum user name above and then "Send message".

    Allan

This discussion has been closed.