mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Capture enter key to submit form
This commit is contained in:
parent
72526307ae
commit
047b9d1ecd
@ -53,11 +53,33 @@ function createNewModal(options={}) {
|
|||||||
|
|
||||||
var modal_name = `#modal-form-${id}`;
|
var modal_name = `#modal-form-${id}`;
|
||||||
|
|
||||||
|
$(modal_name).on('shown.bs.modal', function() {
|
||||||
|
$(modal_name + ' .modal-form-content').scrollTop(0);
|
||||||
|
});
|
||||||
|
|
||||||
// Automatically remove the modal when it is deleted!
|
// Automatically remove the modal when it is deleted!
|
||||||
$(modal_name).on('hidden.bs.modal', function(e) {
|
$(modal_name).on('hidden.bs.modal', function(e) {
|
||||||
$(modal_name).remove();
|
$(modal_name).remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Capture "enter" key input
|
||||||
|
$(modal_name).on('keydown', 'input', function(event) {
|
||||||
|
|
||||||
|
|
||||||
|
if (event.keyCode == 13) {
|
||||||
|
event.preventDefault();
|
||||||
|
// Simulate a click on the 'Submit' button
|
||||||
|
$(modal_name).find("#modal-form-submit").click();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(modal_name).modal({
|
||||||
|
backdrop: 'static',
|
||||||
|
keyboard: false,
|
||||||
|
});
|
||||||
|
|
||||||
// Set labels based on supplied options
|
// Set labels based on supplied options
|
||||||
modalSetTitle(modal_name, options.title || '{% trans "Form Title" %}');
|
modalSetTitle(modal_name, options.title || '{% trans "Form Title" %}');
|
||||||
modalSetSubmitText(modal_name, options.submitText || '{% trans "Submit" %}');
|
modalSetSubmitText(modal_name, options.submitText || '{% trans "Submit" %}');
|
||||||
|
Loading…
Reference in New Issue
Block a user