Return the object that contains the functions when the function is done. then you can chain them.
Here is an example from what I made a while back:
// I extend a class with a new function
HtmlObject.prototype.stop = function () {
clearInterval( this.updater );
this.animationQue = [];
this.updater = undefined;
// Then return the object that initially called the function
return this;
};
So I could use it like object.stop().nextfuntion();
Also, In JQuery the $
is simply a shortcut to a JavaScript function.
I did the same in my test, but then with _
. I must admit it is not as nifty as JQuery but:
var _ = function ( selector, context ) {
var el = new xyvLib();
// This will simply return a collection of HtmlObjects (of which you can find a snipet above)
return el.fn.select( selector, context );
};