[jQuery] Plugin method question
Hi jQuerians,
I'm a web developer with an internet banking provider. I've been preaching the joys of jQuery to them and they're sold. We have lots of people who maintain the sites we host who aren't the most.... we'll say... skilled when it comes to javascript. So, a good deal of my job is to make their job easier. Enter jQuery (obviously).
So I've written my own accordion menus plugin for use at the office which uses a definition list. The reason I wrote yet another one is that I have some very specific requirements from our designers as far as features and config options. Unfortunately, I wrote it at work, and since they were paying for my time, I'm not sure if I can release the code. I'm talking to them now about allowing me to contribute it to the community and I don't have any indication that it won't happen, but I don't feel that I should release the code until I get the all-clear from legal. So I apologize for that, but I'll be sure to let you guys know as soon as I'm allowed to release it, and I'll put together some docs and a demo page.
My question though concerns my need to have multiple instances of the accordion menu on the same page, but with different options. I've implemented the standard plugin architecture complete with the ability to pass in an options object to the plugin function call which overrides the defaults via $.extend(). However, my problem is that I want it to keep the users of the plugin completely out of the JS. So I have it looking for a specific class on a DL and working it's magic from there. So I'm just using the options object passin for more advanced use as a way of overriding the defaults for all menus on the page. So far my method for configuring the individual options is a bit controversial. I'm using the title attribute on the dl tag to hold a config string that looks something like the following.
title="accordion:true,showSpeed:'slow',hideSpeed:'fast'"
I then put curly brackets around the string and eval the whole thing and extend the defaults inside the each function and use removeAttrib() to remove the ugly title. This works great and is very unobtrusive and much easier to grasp for the JS impaired. So all's well except for accessibility. If I use the title attrib like I am, then the default UI things that happen with title and screen readers will have problems if the JS doesn't run. But if I make up an attrib to house my config, then the markup won't validate. What I'm trying so longwindedly to ask is whether the community thinks either of these is the better way to go, or if they have a better solution to the problem.
Thanks in advance for any suggestions/insight. And especially thanks for jQuery and the wonderful array of plugins already available.<br clear="all">
Paul
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/