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 | Contains your Controllers that respond to events, such as a mouseclick. |
| engines | Has self contained macro JavaScriptMVC projects - widgets. |
| models | Models wrap you services and the data they return. |
| resources | non-JavaScriptMVC resources, like prototype. |
| 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','view')
includes controller and view functionality.
To easily create new files, include plugins, and create new applications use the JavaScript generators in jmvc/generators.
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 init.js file in apps/app. The init file includes the controller plugin and a todo controller.
The todo controller adds mouseover/mouseout functionality to any element with id '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/jquery.js?app,development' type='text/javascript'></script>
to
<script src='jmvc/jquery.js?app,test' type='text/javascript'></script>
After you have done this, 'truth_functional_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 and create documentation, install java and type:
js apps/APPNAME/compress.js
Where APPNAME is the name of your application. This only works if you used the generator console
to create the compress.js file. The compressed file will be put in apps/APPNAME/production.js.
Documentation will be put in the docs folder.
To run in production, change compress to production.