简体   繁体   English

Textarea 不会在“输入”按下时换行

[英]Textarea doesn't break line on 'enter' press

I have a project with a lot of libraries, like jQuery , Kendo and AngularJS .我有一个包含很多库的项目,例如jQueryKendoAngularJS After an update with many commits textarea stopped breaking to a new line by [Enter] press.在多次提交的更新后, textarea停止按[Enter]换行。 Maybe, somewhere the event has been unbound or a library interrupts.也许,某处事件已解除绑定或库中断。 I tried to get listeners for the object by JQuery.data(element) , but it got undefined.我试图通过JQuery.data(element)获取对象的侦听器,但它未定义。 How can I debug it?我该如何调试它?

Try this:尝试这个:

$('textbox').keypress(function(e){
  e.stopPropagation();
});

This will prevent any other binded event to be fired when user writes inside the textbox.这将防止用户在文本框内写入时触发任何其他绑定事件。

Found a problem.发现一个问题。 Somewhere in the code:代码中的某处:

$(document).keypress(function (e) {
            if (e.which == 13) {
                e.preventDefault();
            }
        });

It was used to catch 'Enter' press, that led to another page, because menu element was focused on start.它被用来捕捉“Enter”按下,这会导致另一个页面,因为菜单元素专注于开始。

In my case Enter and arrow keys were not working, key-press wasn't detecting the events, changed to key-down, it worked在我的情况下,Enter 和箭头键不起作用,按键没有检测到事件,改为按键,它起作用了

$(document).ready(function () {
$('input, textarea').keydown(function (e) {
          e.stopPropagation();
});
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM