How can we pass the data from a parent to a child template.

When you call the child view from your parent view’s .js file, add in the options like this:

childViews: {
        'Header.Menu': function ()
        {
            return new HeaderMenuView({
                option1: 'option1 value',
                option2: 'option2 value',
            });
        }

Then you can access it from the child view’s initialize function in the its’ view.js file like this:

initialize: function(options) 
{
    console.log(options.option1);
    console.log(options.option2);
}

Leave a comment

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