Class Banana.Application
Defined in: Banana.js.
Main Banana Application components. This object is responsible for loading and running pages. By default the application is accessible through Banana.Application. if you need multiple instances, an application name is required.
typicaly an instance of banana is started with
<div id="target"></div>
<script>
var applicationParameters = {};
applicationParameters.renderTarget = 'target';
applicationParameters.imagedir ='images';
applicationParameters.defaultSection="Home";
applicationParameters.pageTemplate="PageTemplate";
applicationParameters.paths = {}
applicationParameters.applicationName = "foo" //needed if you want to run multiple instances of banana
applicationParameters.paths.pages = "Application.Pages";
applicationParameters.paths.pageTemplates = "Application.Pages.PageTemplates";
var app = new Banana.Application(applicationParameters);
app.run();
</script>
It is also possible to launch multiple instances of banana. Make sure the applicationName is unique
var applicationParameters = {};
applicationParameters.renderTarget = 'target'; //id of the target div
applicationParameters.imagedir ='images';
applicationParameters.paths = {};
applicationParameters.applicationName = "myUniqueApp";
applicationParameters.paths.pages = "Application.Pages";
applicationParameters.paths.pageTemplates = "Application.Pages.PageTemplates";
var pageClass = Banana.Page.extend({
createComponents : function()
{
//do something here
}
});
var page = new pageClass();
var app = new Banana.Application(applicationParameters);
app.run(page);
Following parameters are available for creating a new application
- renderTarget Id of the dom element where the application is rendered in.
- imagedir relative path of various images Banana uses
- paths.pages namespace of Banana Pages (by default "Application.Pages")
- paths.pageTemplates namespace of Banana Template Pages (by default "Application.Pages.PageTemplates")
A new page can be loaded by calling loadPage(String page). The current page will be removed and replaced by the new page. Url history params are restored in case an already visited page is loaded.
- Parameters:
- {Object} settings
Loads a page.
Loads a page by specifying the full namespace name of the page. Additional parameters can be send along. Parameters should be in key => value format stored in an Object. All parameters will be written in the hash section of the url. Loading a page also results in saving the url parameters of the current page. This means that we when we have a url like http://mysite?page=foo#section=Home&id=12 we save the id parameter only. Unless specified we restore the original parameters when the page is reloaded.
- Parameters:
- {string} page
- to be loaded. This is the full namespace name
- {object} key
- value format
- {bool} ignoreHistoryParams
- if true we ignore previous url params.