简体   繁体   English

jquery:非必需textarea的focusout防止触发点击事件的保存按钮

[英]jquery : focusout of non-required textarea prevent trigger click event of save button

I have a form witha textarea as non-required.When I edit the value inside textarea and click save or cancel or delete immediately it doesn't trigger 1st time but triggers in second click. 我有一个texta的表单作为非必需。当我编辑textarea内的值并单击保存或取消或立即删除它不会触发第一次但触发第二次点击。 Like below image 如下图所示

保存表格

And I have my jquery-validate onfocusout event like below but it is not fired 我有我的jquery-validate onfocusout事件,如下所示,但它没有被触发

onfocusout: function(element) {
  if (!this.checkable(element) && element.name in this.submitted) {
    this.element(element);
  }
},

Am I missing anything? 我错过了什么吗? I am using Asp.NET MVC TextAreaFor html helper like below 我正在使用Asp.NET MVC TextAreaFor html helper,如下所示

 @Html.TextAreaFor(m => m.Comment, new {@class = "form-control", data_bind = "value:Comment,attr:{id:commentId}" })

Actually this is not the issue of jquery-validator or kendo-data-binding, the problem occurs because the button moves when filling out the textarea and clearing it. 实际上这不是jquery-validator或kendo-data-binding的问题,问题出现是因为当填写textarea并清除它时按钮会移动。

When you press the mouse key the button is at one place, but when you release it the button has moved and is no longer under mouse pointer. 当您按下鼠标键时,按钮位于一个位置,但是当您松开按钮时,按钮已移动并且不再位于鼠标指针下方。 That's why the click event won't be thrown. 这就是为什么不会抛出click事件。

Check if there is any onblur event handler on the comment field. 检查注释字段上是否有任何onblur事件处理程序。 That could be the reason why the click event isn't thrown from the button. 这可能是没有从按钮抛出click事件的原因。

Or you can use kendo data-value-update="keyup" to bind the data onKeyup . 或者您可以使用kendo data-value-update="keyup"来绑定数据onKeyup

See example: https://dojo.telerik.com/ilaJurol/15 请参阅示例: https//dojo.telerik.com/ilaJurol/15

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

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