Class Loader

A very basic feature is the dynamic class loader. This implements sort of PHP's "require_once" for JavaScript classes.

As always you have to solve a hen-egg-problem. In this case the hen is the class loader, which can lay egg, respecive load classes. Still, you need to load the class loader first manually to load classes dynamically.

Simply load WB.js to gain basic functionality. Well, Wombat usually takes care that essential JavaScript files are loaded. Take a look at the HTML output, there should be something like the examples above.

The source can be found in resource/js/WB.js. This file provides some classes and static functions. On is WB.Class and the function WB.Class.load().

WB.Class.load("WB.Ajax");

Test Load WB.Ajax

WB.Class.load("WB.TestClass"); var foo = new WB.TestClass(); foo.test("This should complete the test");

Load test class

The examples above show how to include a JavaScript class the PHP way. The class loader makes sure, that each class is included only once. This avoids too much request and overriding code.