asp.net-mvcajaxformunobtrusive-ajax

ASP.NET MVC : unobtrusive-ajax for dynamically added forms


I'm loading an Ajax Form inside a popup. the popup content is written client side.

unobtrusive-ajax is not triggered by the form. and its events are not called.

This is because of loading the Ajax Form dynamically. and unobtrusive-ajax is not binded to it.

Is there any method for binding dynamically loaded ajax forms with unobtrusive-ajax ?

Is there any way to fix that?


Solution

  • You need to reset validation for validating dynamically loaded form. after loading form in popup window reset validation:

    var form = $('your form');
    form.removeData('validator');
    form.removeData('unobtrusiveValidation');
    $.validator.unobtrusive.parse(form);