jQuery 1.9.1 == “My PopUp doesn’t close”


With new version of jQuery 1.9.1 maybe you will have a problem when you are updating your data using popup editing or you destroying data, because in the new version of jQuery the successful query returns response different than empty. This makes dataSource doesn’t work properly and the solution is:

  1. Make function that returns empty object if ModelState is valid else returns ModelState.ToDataSourceResult()
  2. Pass ModelState to the function

public JsonResult ModelStateToJsonResult(ModelStateDictionary modelState)
{
return Json(modelState.IsValid ? new object() : modelState.ToDataSourceResult());
}

[AcceptVerbs(HttpVerbs.Post)]
public JsonResult MyUpdateAction([DataSourceRequest]DataSourceRequest request, myViewModel model)
{

//...
return ModelStateToJsonResult(ModelState);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s