Skip to content

Enter key submit on confirms #289

@turtle0x1

Description

@turtle0x1

as pointed out by @abelgomez the $.confirm instances don't dismiss on escape key or submit on enter,

note to self;

fix escape key each confirm should look like $.confirm({backgroundDismiss: true, ...})

fix enter key

Slightly more involved, will have to wrap content in a <form> and then add event listener to onContentReady

$.confirm({
        ...
        content: `<form>
             ...
        </form>`
        ...
        buttons: {
           doSomething: {
              ...
              keys: ['enter'],
              ...
           }
        },
        onContentReady: function () {
            // bind to events
            var jc = this;
            this.$content.find('form').on('submit', function (e) {
                // if the user submits the form by pressing enter in the field.
                e.preventDefault();
                jc.$$BUTTON NAME HERE.trigger('click'); // reference the button and click it
            });
        }
});

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions