jqueryunobtrusive-validationdevexpress-mvc

Prepare validation script


I am using Devexpress MVC controls for developing. One time I wanted to validate dynamically loaded form. So I used this approach. But now I cannot understand why should I use this:

function PrepareValidationData() {
  var form = $('#CityEditForm');
  if (form.executed)
    return;

  form.removeData("validator");
  $.validator.unobtrusive.parse(document);
  form.executed = true;
}

Why should I use form.executed property? Unfortunately googling didn't help.


Solution

  • To my understanding. The executed property is just showcase what can be done. If you make a little tweak, you prevent multiple parsing and similiar stuff.

    In this particular code, the condition have a little to no meaning and it should work without it.