1

I have read several posts on the same topic, but none solved the problem in hand.

I have a button on the page, when clicked, retrieves a PartialView from server & opens it in a jQuery UI Dialog. If users clicks "Save" button on the dialog, I am sending a POST to server to save the record.

jQuery.validate & jQuery.unobtrusive files are both loaded onto the page + client side validation is enabled.

When the View is loaded, I am adding the following:

$.validator.unobtrusive.parse($("#PostForm")); 

Before, posting, I" am checking on:

if ($("#Postform").valid()) {

Yet, I find an error in the console (jquery.validate.js) saying:

Uncaught TypeError: Cannot read property 'form' of undefined

What else is needed to enable unobtrusive validation with dynamic views?

Thanks

Bill
  • 2,026
  • 9
  • 55
  • 99
  • Any news about this subject? I believe this questions is related : http://stackoverflow.com/questions/21020518/jquery-load-with-jquery-tabs-unobtrusive-validation – Hugo Hilário Jan 09 '14 at 13:51

1 Answers1

0

Have you tried serialising the form first?

$.ajax({
   url: "myUrl",
   type: "POST",
   data: $("form").serialize(),
   ...            
Matt
  • 5,573
  • 4
  • 33
  • 37