Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Last active June 9, 2023 11:40
Show Gist options
  • Save alexkingorg/03bcc2004c0bc9145e23 to your computer and use it in GitHub Desktop.
Save alexkingorg/03bcc2004c0bc9145e23 to your computer and use it in GitHub Desktop.

Revisions

  1. alexkingorg revised this gist Apr 27, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jquery-textarea-form-submit-cmd-enter.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ jQuery(function($) {
    // add a handler for form submit (makes an AJAX call)
    $(document).on('submit', 'form.my-class', myFormSubmitHandler);

    // submit form on command + enter if in a textareas
    // submit form on command + enter if in a textarea
    $(document).on('keydown', 'body', function(e) {
    if (!(e.keyCode == 13 && e.metaKey)) return;

  2. alexkingorg created this gist Apr 27, 2015.
    14 changes: 14 additions & 0 deletions jquery-textarea-form-submit-cmd-enter.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    jQuery(function($) {
    // add a handler for form submit (makes an AJAX call)
    $(document).on('submit', 'form.my-class', myFormSubmitHandler);

    // submit form on command + enter if in a textareas
    $(document).on('keydown', 'body', function(e) {
    if (!(e.keyCode == 13 && e.metaKey)) return;

    var $target = $(e.target);
    if ($target.is('textarea')) {
    $target.closest('form').submit();
    }
    });
    });