Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Closed Issue: Unobtrusive Ajax/jquery.validate Conflict [1524]

$
0
0
// Copied from https://aspnet.codeplex.com/workitem/7964
// Vote number : 6
// There are four attached files, but I can't download them. So, I simply added them with the original lnks:
* [jQueryConflict.zip](https://www.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=aspnet&WorkItemId=7964&FileAttachmentId=462922)
* [jQueryAjaxCancel.zip](https://www.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=aspnet&WorkItemId=7964&FileAttachmentId=462923)
* [CauseValidateSample.zip](https://www.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=aspnet&WorkItemId=7964&FileAttachmentId=462924)


I have an Ajax form with a number of validators, which do not have to be satisfied in order to submit the form. As a result, my submit button includes the "cancel" class, which jquery.validate recognizes as a flag to suppress validation.

However, the unobtrusive Ajax script does not respect the "cancel" class on the submit button, and the function $("form[data-ajax=true]").live("submit", function (evt) { ... } proceeds to validate the form. So far, the only cross-browser workaround I can find is to create a script var submitButtonClass, and in the $("form[data-ajax=true] :submit").live("click", function (evt) { ... } function, add the line "submitButtonClass = evt.target.className;", and then in the function $("form[data-ajax=true]").live("submit", function (evt) { ... }, change the if test to "if (submitButtonClass.indexOf('cancel') == -1 && !validate(this))"

Please patch jquery.unobtrusive-ajax.js to handle the "cancel" class gracefully.

Thanks.
Comments: Duplicate of https://aspnetwebstack.codeplex.com/workitem/238

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>