Skip to content

Flame.FormView creates views too many times #27

@jmiettinen

Description

@jmiettinen

All Flame-views inherit from Ember.ContainerView.

In Ember.ContainerView#init there are the following lines:

      if ('string' === typeof viewName) {
        view = get(this, viewName);
        view = this.createChildView(view);
        set(this, viewName, view);
      } else {
        view = this.createChildView(viewName);
      }

Currently, for controls at least, this causes three calls to createChildView: first by the getter, then the direct call to createChildView and at last, the setter also causes a call (see https://github.com/flamejs/flame.js/blob/master/views/form_view.js#L80).

Simply changing control to a normal property does not seem to work ([1]). So on what preconditions am I stepping on and how should this be done correctly?

[1] Simple modification to use simple property instead of a computed property.

        var view = {
            layout: { left: this.get('leftMargin'), right: this.get('rightMargin') },
            layoutManager: Flame.VerticalStackLayoutManager.create({ topMargin: this._focusRingMargin, spacing: 0, bottomMargin: this._focusRingMargin }),
            childViews: ['label', 'control'],
            isVisible: descriptor.get('isVisible') === undefined ? true : descriptor.get('isVisible'),
            label: this._buildLabel(descriptor),
            control: control
        };
        view.control.layout = view.control.layout || {};
        view.control.layout.left = formView.labelWidth + formView.columnSpacing;
        view.control.layout.left.right = formView._focusRingMargin;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions