question on MS jquery.validate.unobtrusive.js file
I am trying to learn more about how the
jquery.validate.unobtrusive.js
file works.
I am confused by the opening syntax which I have abbreviated below...
(function ($) {
var $jQval = $.validator,
adapters,
data_validation = "unobtrusiveValidation";
function setValidationValues(options, ruleName, value) {
options.rules[ruleName] = value;
if (options.message) {
options.messages[ruleName] = options.message;
}
}
... more stuff (deleted)
}(jQuery));
Questions
- jquery.validate.unobtrusive.js loads and has a function that takes a parameter named $. Is this correct?
- I am not used to seeing $ as a parameter name, but I assume it is simply a parameter and $ has no special significance?
- I have not seen the (function(){}(jQuery)); syntax. 开发者_如何学JAVA What is this doing?
Thanks for any insight!
Ok, I have found the answer to this while reading about authoring jQuery plugins.
http://docs.jquery.com/Plugins/Authoring
The $ passed to the function is jQuery itself being passed to a function so that namespace collisions won't occur (which mostly answers my questions 1-3).
精彩评论