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
Syntax
View
(
-
options
Summary
Parameters:
-
options
ObjectAn 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
Syntax
on
(
-
event
-
callback
Summary
Sets an event handler for the view Possible values for event: load, beforeLoad, unload, beforeUnload, ready
Parameters:
-
event
StringDefines in which event the handler will be called
-
callback
FunctionThe 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];
});