YUI 2 in 3: Using YUI 2 DataTable from YUI 3

This example demonstrates the use of YUI 2's DataTable Control from within a YUI 3 instance using the "YUI 2 in 3" support baked into YUI 3.1.0 (post PR1). Here we're using an experimental build, YUI 3.1.0pr2, with preliminary support along with experimental builds of the YUI 3-ready 2.8.0 codebase. Using this approach, we can load the yui2-datatable module directly from the YUI 3 use() statement:

YUI().use("yui2-datatable", function() {
	
	//build datatable here
	
});

The value here is that the YUI 3 seed file, in this case http://yui.yahooapis.com/3.1.0pr2/build/yui/yui-min.js, is able to bootstrap the necessary YUI 2 modules and resolve their dependencies seamlessly — making them effectively first-class modules. This approach does not create a YAHOO global object, as would be the case when loading standard YUI 2 JavaScript components; this approach sandboxes the the YUI 2 functionality just as all YUI 3 modules are sandboxed.

View source for the full code sample.



ericmiraglia.com