I have written some relatively simple jQuery plug-ins, but I am contemplating writing something more advanced in order to keep commonly used methods on the site easily accessible and DRY
For example, I might have something like this for a structure:
plugin - popup - element ... === popup === - login - product ... === element === - shoppingCart - loginStatus ...
So, to bind a popup login popup event, I’d like to be able to do:
$(‘#login_button’).plugin.popup.login();
What’s the best way to do this? Is there a better way of achieving what I want to do?
Cheers,
The way farhan Ahmad did it was pretty much right… it just needs deeper levels to suit your needs your implementation would look like this:
So now if you call:
$("#someDiv").plugin.login();the result will be as expected. I hope this helps.