Hi all, I'm attempting to take the next step into my understanding of jQuery (and JavaScript for the matter) by putting together a simple plugin. Although all the bits are in place; I'm having trouble bringing it all together in a satisfactorily elegant package.
This is what I have so far: http://www.ollicle.com/eg/jquery/autolineheight/ How do I best incorporate the event binding (currently in index.html): $(function(){ // On ready $('#one,#two').autolineheight(); // Window resize $(window).resize(function(){ $('#one,#two').autolineheight(); }); // Font size change - requires Dave Cardwell's jQEm plugin $.jqem.bind(function() { $('#one,#two').autolineheight(); }); }); into the plugin itself: http://www.ollicle.com/eg/jquery/autolineheight/jquery.autolineheight.js I would like to be able to assign the behaviour to selected containers and have the plugin code handle the specific event binding. eg: $('#one').autolineheight({ ratio: .02, minWidth: 20, minLineHeight: 1.6 }); >From the perspective of JavaScript wanna-be; My difficulty with the plugin authoring notes on the jQuery wiki and the existing plugins I looked into - was that they were either: - incomplete (only showing portions of code and not the whole working plugin); - too simple (not fully demonstrating the recommended plugin pattern) or; - too complex (way too much going on for my newbie brain to easily reverse engineer). Perhaps, once properly constructed, a script such as this one would provide a good example for other such as myself who are still learning the ins and out of JavaScript terminology and a result find the written recommendations challenging. The purpose of the script is very simple-adjust the line-height of a container depending on it's relative width (in ems). More about the idea here: http://www.ollicle.com/2005/oct/12/javascript_flex_css.html All thoughts/suggestions are welcome! Cheers Ollie