0

I have different dialog boxes in a page. if i open dialog box and do some form submit if the form is not a valid then it will show error messages and the dialog is closing. again if I reopen the same dialog errors are showing. i want to hide error messages when i reopen the same dialog again.

I have done some code changes in dialog close event it's not working.

$dlg = $("#ItemDialog");

close: function () {
    var popupForm = $dlg.find("form");
    $(popupForm).trigger('reset');
    if ($scope.popupForm) $scope.popupForm.$setPristine();
}
Rajesh GK
  • 67
  • 1
  • 10
  • tip: don't use angular and jQuery together, they overlap and angular (for the most part makes jQuery obsolete) if you use it right – Joe Lloyd Mar 31 '16 at 09:54
  • My current project is in JQuery and Live Project, now started implementing AngularJs so we cannot break existing JQuery functionality, so can you please give me a solution for this situation. – Rajesh GK Mar 31 '16 at 10:07

1 Answers1

0

It seems like close event is not binding correctly. To bind close event of jquery dialog see this https://stackoverflow.com/a/172000/2509344

EDIT To clear form try this:

var popupForm = $dlg.find("form");
popupForm[0].reset();

or if you don't have radio, checkbox and select try this

popupForm.find("input, textarea").not(':input[type=button], :input[type=submit], :input[type=reset]').val("");
Community
  • 1
  • 1
Adnan Umer
  • 3,669
  • 2
  • 18
  • 38