A generator builds DOM tree element for the view it is registered for. It plugs into the Abcs system using the component registration API (ComponentProviderRegistry).
A component creator creates a topmost view for the component's hierarchy and in order to be rendered on a page the view needs to be transformed into a DOM element. That is the responsibility of a generator when the Abcs infrastructure calls its Generator.buildView method.
- Version:
- 16.3.5
- Source:
- See:
-
- Generator.buildView
- ViewGeneratorSupport.buildElement for how to build and add elements for child views.
- ViewGeneratorSupport.applyProperties for how to apply view properties to your HTML template.
Example
define([], function () {
'use strict';
var MyViewGenerator = function() {
};
MyViewGenerator.prototype.buildView = function (view, page) {
var $element = $('<p>Hello i am your paragraph component</p>');
return $element;
};
return MyViewGenerator;
});
Methods
buildView(view, page) → {jQuery}
stable API
Builds the view DOM tree and returns its jquery element.
The method is called by the Abcs infrastructure when it needs the DOM representation of the view to lay and render it on a page. The method is expected to return a jQuery element with a single top element wrapping the view's DOM structure.
Parameters:
Name | Type | Description |
---|---|---|
view |
pages.dt/js/api/View | view to build the DOM structure for. |
page |
pages.dt/js/api/Page | the page the view belongs to |
- Version:
- 16.3.5
- Source:
- See:
-
- Generator example
- ViewGeneratorSupport.buildElement for how to build and add child views.
- ViewGeneratorSupport.applyProperties for how to apply view properties to your HTML template.
Returns:
jQuery element wrapping a single top DOM element containing the complete view's hierarchical structure.
- Type
- jQuery