I would like to register a custom utility / module within YUI3 that is passed one or more custom node(s) and that can be called like this (without having to instantiate it):
YUI().use('myCustomModule', function (Y) {
Y.one('nodeToProcess').myCustomUtility(config);
Y.all('manyNodes').myCustomUtility(config);
});
jQuery offers a similar functionality.
I know that a custom module in YUI3 is defined like this:
YUI.add('myCustomModule', function(Y) {
// my Code here
}, '0.1', {
requires : ['node']
});
But what I don’t understand is how to setup my custom module, so that I can call it like described. Do I have to extend Plugin / Widget class or use Y.Namespace() to get this to work? (see http://www.slideshare.net/caridy/building-yui-3-custom-modules )
You may want to try this: