This is an example page to help get you started. It loads a tiny application at the bottom of this page. The following are a few helpful hints.
JavaScriptMVC applications are organized into folders that contain specific files:
| folder | purpose |
|---|---|
| apps | Contains your application files. Application files are used for including JavaScriptMVC plugins and your files. If you need something in your project, include it here. |
| controllers | Contain your Controllers that respond to events, such as a mouseclick. |
| models | The models contain your project's classes. |
| resources | non-JavaScriptMVC resources, like prototype or jQuery. |
| test | For testing files. |
| views | EJS views. |
In JavaScriptMVC, everything is a plugin. To add functionality, simply use the include function in your application file, located in the apps folder, to include the plugin. For example:
include.plugins('controller','ajax')
includes the controller and ajax functionality.
If you inspect this page's html, you will find a line like:
<script src='jmvc/include.js?app,development' type='text/javascript'></script>
This loads the app.js file in apps. The apps file includes the controller plugin and a todos controller.
The todos controller adds mouseover/mouseout functionality to any element with class 'todo'.
Mouseover the following todo to see it in action!
To test this application, change JavaScriptMVC into test mode by changing development to test. From:
<script src='jmvc/include.js?app,development' type='text/javascript'></script>
to
<script src='jmvc/include.js?app,test' type='text/javascript'></script>
After you have done this, 'todos_controller_test.js' will be loaded in 'test\functional'. Refresh this page, click the functional tab, and click the play button to run the tests.
To compress your application, replace test with compress, and refresh this page. Copy the compressed application to 'apps/app_production.js'.
To run in production, change compress to production.