I have a custom view in which I am trying to create a child view. For a reason that I cannot figure out (everything seems to be executing properly), the template contents of the child view are not displaying.
Here is my code.
Parent view: my-module:views/parent
Parent Template
Parent view: my-module:views/child
In the Chrome Developer Console, I am able to confirm that the child view goes through the rendering process, the data param is transferred and captured properly, but the `templateContent` html does not display in the rendered html.
What am I doing wrong?
Here is my code.
Parent view: my-module:views/parent
PHP Code:
define('my-module:views/parent', ['view'], (View) => {
return class extends View {
template = 'my-module:parent';
setup = () => {
this.wait(
Espo.Ajax.getRequest('my-module/my-entity/' + this.options.id)
.then(result => {
if (result.found) {
this.data = result;
this.createView('child', 'my-module:views/child', {
selector: '#child-panel',
data: result
});
} else {
console.log(result);
Espo.Ui.error(`Error: ${result.error}`);
}
})
.catch(xhr => {
Espo.Ui.error('Error in XHR Fetch');
}),
);
};
data = () => this.data;
});
HTML Code:
<div class="record"> <div class="left"> <div class="panel panel-info headered"> <div class="panel-heading"> <div class="panel-title">My Entity</div> </div> <div class="panel-body panel-body-form"> <div class="row"> <!-- display data templating here --> </div> </div> </div> </div> <div class="side"> <div id="child-panel"></div> </div> </div>
PHP Code:
define('my-module:views/child', ['view'], (View) => {
return class extends View {
templateContent = '<h1>Hello Child View</h1>';
setup = () => {
this.data = this.options.data;
};
data = () => this.data;
}
});
What am I doing wrong?
Comment