Last active
December 22, 2015 23:29
-
-
Save johnnyreilly/6546888 to your computer and use it in GitHub Desktop.
jQuery Remote Validation gets unobtrusively driven additional parameters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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