-
Notifications
You must be signed in to change notification settings - Fork 10
Controller
- tt
- The topcoatTouch object.
- data
- Data used for rendering the page.
- pageName
- The name of the current page.
- template
- The template used to render the page. Unless you have overridden the initialize event, it will be a compiled underscore template.
Adds data to the data property
It is chainable function...
tt.createController('home').
addData('title', i18n.getTranslation('HOME', currentLanguage)).
addData('message', i18n.getTranslation('WELCOME', currentLanguage));Adds an event to the page
This is the preferred way to add events to pages in the MVC model. Events are automatically added when the page is shown and automatically removed when the page is hidden so it is the most efficient event delegator for Topcoat Touch.
tt.createController('home').
addEvent('click', '#buttonHello', function() { console.log('button Hello click'); }).
addEvent('click', '#buttonGoodbye', buttonGoodbyeClickHandler);Note there are default behaviors only for render and initialize. There are also private _pagestart and _pageend events that should not be overriden, unless you want to stop page events from working.
Called when the page has to be rendered
Must return a jquery object or a string. The default behavior is to execute the template with the current data.
tt.createController('home', {title: 'Default Title', calc: 0}, {
// Use mustache rather than underscore templates to render....
render: function() { return Mustache.render(this.template, this.data); }
});Called when the controller is first initialized.
The default action is to load and compile templates/{PAGENAME}.ejs into this.template. Overload this to use Handlebars or Mustache as the template engine.
tt.createController('home', {}, {
initialize: function() {
$.get(templateDirectory + '/' + this.pageName + '.handlebars', function (source) {
this.template = Handlebars.compile(source);
});
}
});**called after the page is loaded ** think of this as a $(document).ready for pages.
called when the page is removed use this to free any objects or memory that are page specific.
called before the render call is made use this setup data just before page rendering
called after the page is rendered but before it is added to the dom.
called after the page is added to the page, but before the page is visible.
called after the page is removed from the dom