LxdMosaic
LxdMosaic copied to clipboard
Enter key submit on confirms
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
});
}
});
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