humzariaz
12/03/2020, 9:54 AMMohammad Sharaf Ali
12/03/2020, 10:43 AMMohammad Sharaf Ali
12/03/2020, 10:52 AMhumzariaz
12/03/2020, 11:07 AMlayout.on('afterShowContent', function () {
console.log("checking"); // executes till this point
viewname = layout.addChildView('<http://Header.Menu|Header.Menu>', function () {
console.log("adding child again..");
return new MyCoolModuleView({
container: container
});
});
});
Please let me know what is wrong with this code snippet.Mohammad Sharaf Ali
12/03/2020, 11:11 AM/** @type {LayoutComponent} */
var layout = container.getComponent('Layout');
if(layout)
{
layout.addChildView('<http://Header.Menu|Header.Menu>', function() {
return new MyCoolModuleView({ container: container });
});
}
Now just place the data-view in the template you want the extension to render
<div data-view="Header.Menu"></div>
Mohammad Sharaf Ali
12/03/2020, 11:21 AMSteve Goldberg
12/03/2020, 11:38 AMPlease let me know what is wrong with this code snippet.The primary thing is that you set your
addChildView
call to be set to a variable and then never called that variable. So no child view was added because you never told it to add one.
Mohammad's code sample is fine, although I don't agree with needing to add a new data-view.Mohammad Sharaf Ali
12/03/2020, 11:43 AMhumzariaz
12/03/2020, 11:47 AMSteve Goldberg
12/03/2020, 11:47 AMhumzariaz
12/03/2020, 11:47 AM/** @type {LayoutComponent} */
var layout = container.getComponent('Layout');
layout.addChildView('<http://Header.Menu|Header.Menu>', function () {
console.log("adding child")
return new MyCoolModuleView({
container: container
});
});
Works fineSteve Goldberg
12/03/2020, 11:48 AMhumzariaz
12/03/2020, 11:52 AMMohammad Sharaf Ali
12/03/2020, 11:52 AMMohammad Sharaf Ali
12/03/2020, 11:59 AM