API Docs for:
Show:

View

Defined in: js/view.js:1
Module: View

Summary

The View class handles each view of the application. A list of views is specified in the applications options and the files are loaded from the "views" folder. Each view has a viewName.js, viewName.html and viewName.css files.

Constructor

View

Defined in js/view.js:1

Syntax

View

(
  • options
)

Summary

Parameters:

  • options Object

    An object defining options for the current view.

    • constructor - A function that will be run after the view has loaded (optional).
    • animation - a string defining the type of animation used to show this view (one of: "slide-left", "slide-right", "none").

Item Index

Methods

Methods

on

Defined in js/view.js:233

Syntax

on

(
  • event
  • callback
)

Summary

Sets an event handler for the view Possible values for event: load, beforeLoad, unload, beforeUnload, ready

Parameters:

  • event String

    Defines in which event the handler will be called

  • callback Function

    The function to be called when the event is fired.

Returns:

View

Example:

// Simple example

m.app.route("^#index$", app.view("index"));

m.app.view("index").on("load", function(self) {
   console.log("Index view is loaded."); 
});

// With parameters

m.app.route("^#product/(.*)", app.view("product"));

m.app.view("product").on("load", function(self) {
   console.log("Product Id: " + self.params[0];
});