HTML and CSS Reference
In-Depth Information
* Initializes all of the controllers. You might not want to do this
* automatically, so you can use the initScripts method to execute it.
*/
initScripts: function(){
_controller.movies = new app.controller.movies();
_controller.favorites = new app.controller.favorites();
_controller.favorites.list();
}
}
})();
The init method will simply initialize all of the controllers and load the first
controller.
For your convenience, the full bootstrap is shown next.
var app = app || {};
app.bootstrap = (function(){
/**
* Create the controller object
* You explicitly declare the movies and favorites
* controllers
*/
var _controller = {
movies: null,
favorites: null
}
/**
* Add a click event listener over the entire document
* It will delegate clicks for controllers to the
* controller and action
*/
document.addEventListener("click", function(event){
var target = event.target;
/**
* Crawl up the DOM tree from the target element until
* the link surrounding the target element is found
*/
while(target.nodeName !== "A" && target.getAttribute('data-controller')
== null && target.getAttribute('data-action') == null){
// We've reached the body element break!
if(target.parentNode.nodeName == 'HTML'){
target = null;
break;
}
 
Search WWH ::




Custom Search