开发者

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

  1. jquery.validate.unobtrusive.js loads and has a function that takes a parameter named $. Is this correct?
  2. I am not used to seeing $ as a parameter name, but I assume it is simply a parameter and $ has no special significance?
  3. 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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜