Initializing application¶

The on_page_loaded event is the first event triggered by an application on the client.

The new project uses on_page_loaded event handler to dynamically build the application’s main menu and attach the on click event handler to menu items using JQuery.

function on_page_loaded(task) {


    if (task.safe_mode) {
        $("#user-info").text(task.user_info.role_name + ' ' + task.user_info.user_name);
        .click(function(e) {

    if (task.full_width) {

    task.create_menu($("#menu"), $("#content"), {view_first: true});


This event handler uses JQuery to select elements from the index.html to set their attributes and assign events.

<div id="container" class="container" style="display: none">
    <div class="row-fluid">
        <div class="span6">
            <h3 id="title" class="muted"></h3>
        <div class="span6 logging-info">
            <span id="user-info"></span>
            <a id="log-out" href="#" style="display: none">Log out</a>
    <div class="container">
        <div id="taskmenu" class="navbar">
            <div class="navbar-inner">
                <ul id="menu" class="nav">
    <div id="content">

Finally, the create_menu method of the task is called to dynamically create the main project menu.