LxdMosaic icon indicating copy to clipboard operation
LxdMosaic copied to clipboard

Enter key submit on confirms

Open turtle0x1 opened this issue 4 years ago • 1 comments

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
            });
        }
});

turtle0x1 avatar Nov 17 '20 23:11 turtle0x1

The problem with this is that it requires adding additional code to block pressing escape once the user has clicked the button - this isn't a find and replace job so it becomes quite a big time investment.

Going to leave it open for the time being and move off 0.11.0

turtle0x1 avatar Dec 28 '20 22:12 turtle0x1