1

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?

Manoochehr Dadashi
  • 715
  • 1
  • 10
  • 28

2 Answers2

3

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);
Mohsen Esmailpour
  • 11,224
  • 3
  • 45
  • 66
  • 2
    thanks for your answer. Your answer is right. but my problem is not about validations. I already done this workaround. and validation is working. – Manoochehr Dadashi Jan 02 '15 at 15:33
2

I found the problem. unobtrusive-ajax is working with dynamically added forms. and events are binded. Problem was about copying my markup inside popup and I had two items with same ID. jquery selectors was not working.

I removed my original markup (that I was copying inside popup). and everything is ok now.

Manoochehr Dadashi
  • 715
  • 1
  • 10
  • 28