Skip to content

Bootnode

tellijo edited this page Dec 13, 2012 · 3 revisions

Concept

The bootnode is a simple way to load necessary javascript on the fly. If you have a feature not really used or available across all the site, you may like not to specify associated javascript in the head. So bootnode allows you to define it in the html markup using data attributes.

Implementation

Activation

In the core building using tetra.extend({conf:{}}) (cf. Presentation part), you have to set the enableBootnode parameter in the conf to true. Il will activate this feature for all applications.

Definition in markup

Bootnode definition must be set in the container element of the application interface. We need to have 3 parameters :

  • class="bootnode": the bootnode className allows the core to find which element is reactive to bootnode actions.
  • data-view="appName/viewName": the path to the view object associated to the html markup.
  • data-comp="compName": replace the data-view attribute if you want to load a packed javascript with a custom name compName.
  • data-event="click": the event that will be handled to launch js retrieving and action call. This attribute supports click, mouseover and focus event type.
<div class="bootnode" data-view="likeApp/likeButton" data-event="click">  
...  
</div>

or

<div class="bootnode" data-comp="likePackage" data-event="click">  
...  
</div>

Dependency management system

Controller and model objects will be retrieved according to the use parameter of the view and controllers. The core build a chain of dependencies, download each js file and initialize them in the following order: models then controllers then view. After all these steps are completed, the event action is called.