twoBirds Lib 2.0 Released
Written by on April 2nd, 2007 in Ajax News.
twoBirds Lib 2.0, a library that handles on-demand loading problems, has been released by Frank Thuerigen.
It works asynchronous and allows out-of-order execution of JS code. JS objects can recursively load other JS objects.
Take a look at the prototype to see it in action:
In the “user” field top right enter a character combination and hit return to enter… in the menu click on “communication” and then “chat”… enjoy your chat. A closer look using firebug etc. will reveal that all element parts are loaded separately, simultaneously and out-of-order, on-demand when you click on a link.
The system itself ensures that elements are being displayed once all the necessary files have loaded. Note: IE users may have to add this site to the list of trusted sites, since login requires a cookie. All demo windows are accessible without login.
There is no more loading after the first display of an element, all data and code was cached and on re-selection displayed right away causing no server traffic. The chat will periodically retrieve new lines, of course…
Example Code
-
-
application.index_body = {
-
-
init: function (pDivId) {
-
tb.element.require(
-
“[ [ ‘css’, ‘application’, ‘index_body’ ], ” +
-
” [ ‘tpl’, ‘application’, ‘index_body’ ], ” +
-
” [ ‘js’, ‘tb’, ‘effect.fadeTo’ ] ]”,
-
‘application.index_body.display( “‘ + pDivId + ‘” )’ ,
-
true
-
);
-
},
-
-
display: function (pDivId) {
-
var myHtml = tb.loader.tplget(’application’,’index_body’);
-
tb.div.replace( pDivId, myHtml );
-
tb.element.require(
-
“[ [ ‘js’, ‘application’, ‘menu’ ], ” +
-
” [ ‘css’, ‘application’, ‘menu’ ], ” +
-
” [ ‘tpl’, ‘application’, ‘menu’ ], ” +
-
” [ ‘js’, ‘application’, ‘user_greeting’ ], ” +
-
” [ ‘css’, ‘application’, ‘user_greeting’ ], ” +
-
” [ ‘tpl’, ‘application’, ‘user_greeting’ ], ” +
-
” [ ‘js’, ‘application’, ’submenu’ ], ” +
-
” [ ‘css’, ‘application’, ’submenu’ ], ” +
-
” [ ‘tpl’, ‘application’, ’submenu’ ], ” +
-
” [ ‘js’, ‘application’, ‘window’ ], ” +
-
” [ ‘css’, ‘application’, ‘window’ ], ” +
-
” [ ‘tpl’, ‘application’, ‘window’ ] ]”
-
);
-
tb.element.show( ‘toprightcontainer’ , ‘application’, ‘user_login’ );
-
}
-
};
Source: Ajaxian
Original Article: http://ajaxian.com/archives/twobirds-lib-20-released