Hello All, I am trying to add a child view to Hea...
# suitecommerce
s
Hello All, I am trying to add a child view to Header.Menu.View. But couldn't succeed. I am working on SCA 2019.2 release. I added a new Module in the Extension folder with name ExtendedMenu, added a Javascript view File with name Header.Sub.Menu My Directory looks like below: core |__ Advances |__ Header |__ JavScript |__ Header.Menu.View.ts |__ Extensions |__ ExtendedMenu |__ JavaScript |__ Header.Sub.Menu.View.ts |__ Templates |__ header_sub_menu.tpl.d.ts theme |__ ExtendedMenu |__ header_sub_menu.tpl I have registered my new Module in distro.js and also added as dependency in shopping application. I try to add the child view in Header.Menu.View.ts as follows
childViews: {
//all other child views,
'HeaderSubMenu' : function () {
return new HeaderSubMenu();
}
}
Also, I have added the data view in header.tpl as
<div class="sub-menu" data-view="HeaderSubMenu"></div>
Can any one help me with what I am doing wrong? @Steve Goldberg @Flo
s
1. You should not be editing source files directly. You should be either creating custom modules or extensions, and then using the extensibility API to add your child views. 2. What error are you getting?
s
Hey Steve, thanks for quick response. The above example is just to verify if I am doing anything wrong. I Extended the Module file and added my ChildView from it. I am not getting any error on console but my data-view is not filling with the Child template.
@Steve Goldberg I am not using Extension as I have to add the Menu in all the future extensions.
s
OK, well would you please trying using the extensibility API and good practice development practices first? What you've done seems OK but it's hard to tell without context; I'd much prefer you follow our recommended paths before claiming that they don't lead anywhere