Stand alone editor

Stand alone editor

tchristforttchristfort Posts: 22Questions: 7Answers: 0
edited April 2018 in Editor

I use a stand-alone editor using this definition:

$("#passwordButton").on('click', function() {
    pwEditor
            .buttons( {
                label: "Gem",
                fn: function () { this.submit(); }
            } )
            .edit(<?PHP if (isset($prot)) {echo $prot->getUserID();} ?>, false)
            .set( 'users.location', 2)
            .open();
    
})

var pwEditor;

$(document).ready(function() {
    pwEditor = new $.fn.dataTable.Editor( {
        ajax: "users_server.php",
        fields: [
            { 
              label: "Nyt kodeord:",
              name: "users.userPass",
              type: "password"
            }, {
              label: "Gentag nyt kodeord:",
              name: "users.repeatPass",
              type: "password"
            }, {
              label: "Nuværende kodeord:",
              name: "users.currentPass",
              type: "password"
            }, {
              label: "Lager:",
              name: "users.location",
              type: "select",
              options: [
                  { label: 'Nybøllegård', value: 1 },
                  { label: 'Iselingen', value: 2 }
              ]
            }
        ]
    
    } );
    

} );

The editor will submit correctly, however when results are returned form back-end I get the error:

Uncaught Could not find an element with data-editor-id of: row_15

It is correct that I have not defined any element as I do not wish to use or show the return values if back-end updates correctly, just close the editor. How do I achieve this?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    You could try a little workaround:

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

    That will replace the data from the server for the row with just an empty array, letting Editor skip over it.

    Allan

  • tchristforttchristfort Posts: 22Questions: 7Answers: 0

    Did the trick, thank you

This discussion has been closed.