How to target individual elements within one plugin?
I'm working on a plugin to manipulate form fields.
Most plugins I've seen are implemented like this:
- $('#element').myPlugin({
- option1: value,
- option2: value,
- option3: value
- });
But in the case of form fields, I think a more efficient structure would be something similar to the bassistance validation plugin:
- $("#form").myPlugin({
- fields: {
- "formfield1": {
- option1: value,
- option2: value,
- option3: value
- },
- "formfield2": {
- option1: value,
- option2: value,
- option3: value
- }
- }
- });
Q: How would you setup a plugin like this?