Set default button for enter key

Set default button for enter key

Loren MaxwellLoren Maxwell Posts: 406Questions: 99Answers: 10
edited September 2018 in Editor

Somewhat of a related question for this post:
https://datatables.net/forums/discussion/52211/leave-modal-open-after-adding-record

After setting it up, I have three buttons -- "Cancel", "Save", and "Save and add another".

Is there a way to specify which button will be pressed on the editor form when the user hits the "Enter" key?

By default it presses the "Save" key but I might like to set it to "Save and add another".

This question has an accepted answers - jump to answer

Answers

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

    Is there a way to specify which button will be pressed on the editor form when the user hits the "Enter" key?

    No I'm afraid not. The entry key doesn't actually trigger any of the the buttons - instead it just calls submit().

    That said, there is an alternative approach you can take. The form-options object has an onReturn option that can be used as a function. You could define that function to be:

    function () {
      this.submit( () => {
        this.create();
      } );
    }
    

    which should do the job.

    Allan

This discussion has been closed.