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?

4

2 回答 2

2

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);
于 2015-01-02T15:25:01.950 回答
1

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.

于 2015-01-02T15:37:10.980 回答