HTML and CSS Reference
In-Depth Information
// If they don't exist, throw an exception
throw "Action " + action + " for controller " + controller + " doesn't
appear to exist";
return;
}
}
...
})();
You can access properties within an object much like an array. Except rather
than passing an index, you can pass a string or a variable. For example:
_controller["movie"]["show"]
is the same as calling
_controller.movie.show
except you can now use variables to make the call within the brackets in the first
example.
The parameters passed to the controller's action will need to be converted from
a string to a JSON object. You can do this with the JSON.parse() method, as
shown in the following code.
var app = app || {};
app.bootstrap = (function(){
...
/**
* If there's a target, then process the link action
*/
if(target){
...
// Check to see whether the params exist
if(params){
try {
// If they do, then parse them as JSON
params = JSON.parse(params);
} catch (e) {
/*
* If there's a parsing exception, set the
* params to be null
*/
params = null;
return;
}
 
Search WWH ::




Custom Search