Skip to content

Possible bug with the auto-generated prepareView() ? #194

@claydodo

Description

@claydodo

return new subview.constructor({
parent: self
});

The auto-generated prepareView function does not provide an el argument to the constructor. As a result, the returned view instance's el may be undefined, causing container.appendChild(view.el) in renderSubview to fail. Is this a bug, or am I using it in a wrong way?

renderSubview: function (view, container) {
if (typeof container === 'string') {
container = this.query(container);
}
if (!container) container = this.el;
this.registerSubview(view);
view.render();
container.appendChild(view.el);
return view;
},

I found this issue when trying to use the example provided in ampersand-view's doc:

module.exports = AmpersandView.extend({
    ...
    subviews: {
        ...
        tab: {
            hook: 'switcher',
            constructor: ViewSwitcher
        }
    }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions