Extending template file

Alternative way for extending the template file, in 2020.2 later SCA has got some updates in the View, so normal extend method we use wont work.

_.extend(View,{template:newtemplate.tpl})

Alternative solution is Create a custom view and replace the existing one

define(
'DEMO'
, [
"Orginal.View", 'Custom.tpl'
]
, function (
orgView, custom_tpl
) {
'use strict';    
return {
        mountToApp: function mountToApp(container) {
            class CustomOrgView extends orgView {
                template = custom_tpl; // Updating the existing template
            }

            var layout = container.getComponent('Layout');
            layout.on("afterShowContent", function () {
                const customView = new CustomOrgView({ application: container });
                var siteSelector = jQuery('#abcd'); // selector of corresponding view
                siteSelector.html(customView.render().$el.html());
            });

        }
    };
});

Leave a comment

Your email address will not be published. Required fields are marked *