View

Summary

The abstract base class for views.

Description

The View abstract class is the abstract base class for views in Altitude MVC/MVP applications.

In Altitude, views should be separated from the domain ("dumb view").

Examples

Basic Usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import Altitude.Frontend;
 
external jQuery, $; // Import jQuery (optional)
 
class Contact : View
{
    // Construct a view based on the specified template
    Contact() {
        super(
            """
            <div class="contact">{{firstName}} {{lastName}}</div>
            """
        );
    }
 
    // Describe how the HTML gets rendered once the model changes
    override renderTemplate(string html) {
        $("#contact").html(html);
    }
}

Methods

  • html

    The generated HTML output.

  • initialize

    Performs the initial render.

  • renderTemplate

    The template method for specifying how the generated HTML should be rendered.

  • template

    The compiled Handlebars template.

  • updateOnly

    Updates the view in response to specific changes in the model.

  • View (Constructor)

    Constructs a view and binds it to the specified Handlebars template.

Share

HTML | BBCode | Direct Link