问题
I need to avoid submitting an x-editable select by pressing enter key, and allow the user to only submit it by clicking the submit button.
I can't find any reference in the documentation about how to achieve this in the x-editable.
Here's x-editable initialization code:
$(".xe-user").editable({
mode : "popup",
type : "select",
source : webroot + "/index.php/user/getUser",
name : "Id_user",
toogle : "manual",
url : url
});
回答1:
Do this
$('.data-item').on('shown', function(e, editable) {
editable.input.$input.keypress(function (e) {
if (e.which == 13) {
return false;
}
});
});
Where '.data-item' is the editable element(s). You'll need to have your own "save" button to submit the form if you disable submitting via the enter button.
来源:https://stackoverflow.com/questions/30865315/x-editableselect-avoid-submitting-on-pressing-enter-key