[jQuery] jQuery plugin structure help
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
});