mojo


See Also Application, models.Base, models.Collection, views.Base, views.List, views.Stack, router

This package comes pre-bundled with all the default Mojo plugins, including the views, models, template engine, and http router.

Installation

NPM:

npm install mojojs --save-exact

Browser:

First download https://raw.githubusercontent.com/mojo-js/mojo.js/master/build/mojo.min.js, then insert it in the <head /> of your document:

application

the application instance

application.views

the property set by the views plugin. See http://www.mojojs.com/docs/api/application#views for documentation.

mojo.application.models.register({
  main: MainView,
  confirmPopup: ComfirmPopupView,
});

application.paperclip

the property set by the template plugin.

var tpl = application.paperclip.template("hello {{name}}");
document.body.appendChild(tpl.bind({ name: "Jim Carrey" }).render());

application.models

the property set by the models plugin. See http://www.mojojs.com/docs/api/application#models for documentation.

mojo.application.models.register({
  person: PersonModel,
  people: PeopleCollection
});

models

The models namespace. Contains Base, Collection.

var people = new mojo.models.Collection([
  new mojo.models.Base({ name: "Johnny Depp"    }),
  new mojo.models.Base({ name: "Tom Cruise"     }),
  new mojo.models.Base({ name: "Angelina Jolie" })
]);

views

The views namespace. Contains Base, Stack, and List.

var baseView = mojo.views.Base();
var stackView = mojo.views.Stack();
var listView = mojo.views.List();