This section describes how to load a widget at startup.
The init
function in the main.js
file loads the widget. The function is triggered by the init
event of the widget body element. The following code illustrates how to assign a function to the onload
event handler, <body onload="javascript:init();">
:
<body onload="javascript:init();"> function init() { // Disable cursor mode. widget.setNavigationEnabled( false ); // Create the views. widgetMenu = new Menu(); loginScreen = new LoginScreen(); updateScreen = new UpdateScreen(); searchScreen = new SearchScreen(); settingsScreen = new SettingsScreen(); // Show first view. widgetMenu.activate( Menu.LOGIN_SCREEN ); }
The above code creates all the widget views and activates the Login view screen by calling the activate
function assigned to the menu option.