postSubmit event not always raised in Editor 1.6.3

postSubmit event not always raised in Editor 1.6.3

sliekenssliekens Posts: 97Questions: 17Answers: 2
edited June 2017 in Bug reports

One of the release notes for Editor 1.6.3 states the following:

postSubmit could be triggered with incorrect parameters when an error state was returned from the server in response to the Editor Ajax request.

By looking at the diff between 1.6.2 and 1.6.3, I found that all calls to _event( 'postSubmit', ...) have been removed from Editor.prototype._submitSuccess and Editor.prototype._submitError. Instead, the event is raised inside Editor.prototype._ajax.

Unless I'm missing something, that means the event is not always raised by Editor 1.6.3 because the _ajax method is not always used. For example: stand-alone tables probably don't use this code path.

    // Submit to the server (or whatever method is defined in the settings)
    var submitWire = this.s.ajax || this.s.ajaxUrl ?
        this._ajax :
        this._submitTable;

Replies

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin

    You aren't missing anything. I did.

    Thanks for pointing that out, I'll have it fixed soon.

    Allan

  • rduncecbrduncecb Posts: 125Questions: 2Answers: 28

    I'm also encountering this issue. As the reporter of the initial issue that prompted this change I am running into this issue after upgrading to Editor 1.6.3. By using a custom function for the ajax setting I now don't see the postSubmit event.

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin

    Thanks for the report! I'll post back in this thread with the fix and update.

    Allan

  • rf1234rf1234 Posts: 2,958Questions: 87Answers: 418
    edited July 2017

    Similar issue here. The application crashes on a simple SQL dup key when I use "postSubmit"
    The event is being triggered but the json object is a null value!

    An SQL error occurred: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'SEK-2010-02-11 00:00:00' for key 'UniqueIndexForex'
    
    Fatal error: Call to a member function insertId() on boolean in E:\xampp\htdocs\lgf\DataTables\php\Editor\Editor.php on line 1624
    

    This is my post submit statement which doesn't work any more:

    forexEditor
            .on( 'postSubmit', function ( e, json, data, action ) {
                if (json.error) {
                    var sqlDupKey = json.error;
                    sqlDupKey = sqlDupKey.substring(0, 15 )
                    if (sqlDupKey == 'SQLSTATE[23000]') {
                        json.error = 'Sorry, this rate already exists!';
                    }
                }        
            });
    

    For the sake of completeness: If there is no SQL error the event is also triggered and the JSON object is not null. So something is wrong with Editor's error handling I guess.

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin

    Its taken longer than I had hoped to dig into and resolve this - my apologies.

    I've committed the fit locally and I will release a bug fix version of Editor with this change (and other fixes) next week.

    Regards,
    Allan

  • sliekenssliekens Posts: 97Questions: 17Answers: 2

    Thanks. :)

    FYI the company where I use DataTables and Editor has decided not to renew my contract. I will not be able to test fixes released after the first week of August.

This discussion has been closed.