Skip to content

Instantly share code, notes, and snippets.

@johnnyreilly
Last active December 22, 2015 23:29
Show Gist options
  • Save johnnyreilly/6546888 to your computer and use it in GitHub Desktop.
Save johnnyreilly/6546888 to your computer and use it in GitHub Desktop.
jQuery Remote Validation gets unobtrusively driven additional parameters.
(function($) {
var originalRemote = $.validator.methods.remote;
$.validator.methods.remote = function(value, element, param) {
param.data = {};
if (param.dataSelector) {
var dataToSend = $(element)
.closest(param.dataSelector)
.find(":input")
.serializeArray();
$.each(dataToSend, function() {
param.data[this.name] = this.value;
});
}
return originalRemote.call(this, value, element, param);
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment