HTML and CSS Reference
In-Depth Information
...
})();
The first thing to do is to prevent the event from being handled by the browser.
This will prevent the browser from attempting to load a dead link. You will then
need to get the controller, action, and params data attributes from the element.
var app = app || {};
app.bootstrap = (function(){
...
/**
* If there's a target, then process the link action
*/
if(target){
...
// Get the controller, action, and params from the element
var controller = target.getAttribute('data-controller'),
action = target.getAttribute('data-action'),
params = target.getAttribute('data-params');
}
...
})();
You will then need to verify that the controller and action exists. Check to see
whether the controller exists in the _controller instance variable, and that the
action exists within the controller, as shown in the following conditional
statement.
var app = app || {};
app.bootstrap = (function(){
...
/**
* If there's a target, then process the link action
*/
if(target){
...
/*
* Check to see whether the controller exists in
* the bootstrap and the action is available
*/
if(typeof _controller[controller] === 'undefined'
|| typeof _controller[controller][action] === 'undefined'){
 
Search WWH ::




Custom Search