Last updated by smaldini 1 year ago
Overview
This plugin supplies jQuery Validation resources, and depends on the jQuery plugin to include the core jquery libraries.
Use this plugin in your own apps and plugins to avoid resource duplication and conflicts.
Note for developers working with this plugin
This plugin just provides the resources and a tag to include them. It must not include tags to add new functionality or wrap jQuery Validation features.If you need a newer version of jQuery Validation than is currently available with this plugin you can update this plugin in grails SVN yourself. The original author has no desire to manage releases - provided you follow the clear conventions set out, all users of this plugin will be happy! Be my guest and release new versions as and when - just don't break anything for existing users. That means:
- Always include all jQuery Validation resources such as jquery.validate.js, jquery.validate.pack.js and additional-methods.js.
- Don't add any functionality tags to this plugin
- Only update the jquery core library dependency when absolutely necessary, i.e. when jQuery Validation requires it.
IMPORTANT: Make sure the version number of the plugin and the jQuery Validation distribution is the same.
Conventions
The version number of this plugin must always follow the version number of the jQuery Validation version it bundled.
E.g. the first release of this plugin is 1.7 - because it ships jQuery Validation 1.7. If jQuery Validation upgrades to 1.8 or similar, this plugin would need to be upgraded to use it and use the version number 1.8.
The key part is that any apps/plugins can install or dependsOn "jqueryValidation" of a given version e.g. 1.7 to pull in that version of jQuery Validation.
This plugin must dependsOn the minimum version of jQuery required by the jQuery Validation version. E.g. in this release that is jQuery 1.4.2.7 which is a separate grails plugin that also matches this versioning convention
Tags
There is one tag - <jqval:resources/> - which pulls in the resources needed. It does
not currently pull in the core jQuery resources, you should use the <g:javascript lib="jquery"/> tag for that.
Configuration
After you installed the plugin, the following default configurations will append to your project's Config.groovy:
- jqueryValidation.packed = true
- jqueryValidation.cdn = false // false or "microsoft"
- jqueryValidation.additionalMethods = false
Packed version of Javascript file
You can choose if the packed version of the .js shoud be used (or not) by using the following config parameter
jqueryValidation.packed = true|falsedefault: serve packed
Microsoft CDN
If yout want to load the resources from the Microsoft CDN (which makes a lot of sense for high traffic sites), you can specifiy
jqueryValidation.cdn = 'microsoft'default: loading from CDN is disabled.
Additional Validation Methods
jqueryValidation.additionalMethods = true|falsedefault: additional-methods.js not served.
Using the resources framework (recommended)
If you are using the
Grails resources framework you simply include a "use" tag in your GSP or layout as normal and include the names of the modules you need. The modules exposed by this plugin are:
- jquery-validate - the packed jquery validate provided by the plugin
- jquery-validate-dev - the not packed JS
- jquery-validate-additional-methods - for additional Methods js
Using the Grails Resource, you can override these resources by using the "js" id on these modules, for instance to use CDN.