Search code examples
javascriptjquerytextareakendo-mvvmonfocusout

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. Like below image

save form

And I have my jquery-validate onfocusout event like below but it is not fired

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

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

Solution

  • 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.

    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.

    Check if there is any onblur event handler on the comment field. That could be the reason why the click event isn't thrown from the button.

    Or you can use kendo data-value-update="keyup" to bind the data onKeyup.

    See example: https://dojo.telerik.com/ilaJurol/15