HTML and CSS Reference
In-Depth Information
}
}
...
})();
JSON.parse will throw an exception if the JSON validation fails. You will need to
catch this and set the params to null.
The final thing to do is to execute the controller action.
app.bootstrap = (function(){
...
/**
* If there's a target, then process the link action
*/
if(target){
...
/**
* Execute the controller within the context of the target.
* This will allow you to access the original element from
* the controller action. Also pass the parameters from the
* data-params attribute.
*/
_controller[controller][action].call(target, params);
}
...
})();
Because the application uses localStorage to store movie favorites, you will
need to initialize the local storage variables.
app.bootstrap = (function(){
...
/**
* Set up the local storage by checking to see whether
* the favorites item exists
*/
if(!localStorage.getItem('favorites')){
// if it doesn't, create an empty array and assign it to the storage
var favorites = [];
localStorage.favorites = JSON.stringify(favorites);
}
})();
As mentioned before, you will need to create methods to access the controllers
and initialize them.
 
Search WWH ::




Custom Search