This project is read-only.


Loading a Module

The entry point to a module is a javascript file url. You can load a module by registering the module name and url through the API and calling the load method when it is required. This will add a script tag to the DOM and download your module js file.
  name : 'my-module',
  url: ''

Module Name

The name of the module is important as it is used to reference the module through the jmvc API. Since it can be used in DOM element idvalues, it should be alphanumeric and contain no spaces (hyphens are fine) or special characters.
  • good name
    • 'my-module'
    • 'the-best-module'
  • bad names
    • 'a bad module name'
    • 'another bad module name#'


jmvc.modules is a collection of all the registered modules.

jmvc.modules.add method

jmvc.modules.add is used to register your module with the API.
The jmvc.modules.add method also accepts arrays.
  {  name : 'my-module1',  url: ''}
  {  name : 'my-module2',  url: '', onload: function(){ this.action('my-controller', 'index'); }}
The onload event will fire when the module has loaded. If passed to the add method it will also cause the module to automatically load. The onload event can be also be set in the module itself. The this keyword in the onload event will be the module object.

jmvc.module method

The jmvc.module method will return the module object for the supplied name. It will create a new module with the supplied name if none already exists.
var module = jmvc.module('my-module');

Last edited Jun 26, 2014 at 10:47 PM by dpembroke, version 1