humzariaz
01/26/2021, 7:40 AMreturn {
mountToApp: function mountToApp(container) {
// using the 'Layout' component we add a new child view inside the 'Header' existing view
// (there will be a DOM element with the HTML attribute data-view="Header.Logo")
// more documentation of the Extensibility API in
// <https://system.netsuite.com/help/helpcenter/en_US/APIs/SuiteCommerce/Extensibility/Frontend/index.html>
/** @type {LayoutComponent} */
var layout = container.getComponent('Layout');
layout.addChildView('Header.Logo', function () {
console.log('Inner this', this)
return new HomeBannerView({
container: container
});
});
Doesn't Work
function AddChild(container, layout) {
layout.addChildView('Header.Logo', function () {
console.log("adding Child View")
return new HomeBannerView({
container: container
});
});
}
return {
mountToApp: function mountToApp(container) {
// using the 'Layout' component we add a new child view inside the 'Header' existing view
// (there will be a DOM element with the HTML attribute data-view="Header.Logo")
// more documentation of the Extensibility API in
// <https://system.netsuite.com/help/helpcenter/en_US/APIs/SuiteCommerce/Extensibility/Frontend/index.html>
/** @type {LayoutComponent} */
var layout = container.getComponent('Layout');
AddChild(container, layout);
}
};
});
Steve Goldberg
01/26/2021, 11:12 AMmountToApp
is passed the container object, which is what you're using to get the Layout component. But you have wrapped it in a function that uses it. The outside function will run first and at that time, layout
will be undefined.humzariaz
01/26/2021, 12:34 PMSteve Goldberg
01/26/2021, 12:37 PMaddChild
as a property of the returned object and then call it in your mountToApp
with this.addChild(...)
Steve Goldberg
01/26/2021, 12:38 PMhumzariaz
01/27/2021, 5:19 AMmountToApp: function mountToApp(container) {
/** @type {LayoutComponent} */
var layout = container.getComponent('Layout');
function addChild(){
layout.addChildView('Header.Logo', function () {
console.log("adding Child View")
return new HomeBannerView({
container: container
});
});
}
}
it didn't work for me.humzariaz
01/27/2021, 5:37 AMSteve Goldberg
01/27/2021, 11:17 AM