X-editable(select): Avoid submitting on pressing enter key

不想你离开。 提交于 2020-01-03 06:43:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!