Skip to content

Cannot create Views dynamically #2597

Closed

Description

@Myslik

Maybe I am missing something, but probably since 626a4e7#L1R922 I am no longer able to create views dynamically with templateName specified.

App.MyView.create({ templateName: 'tempname' }).render();

This snippet fails saying it cannot find the template specified. It is the smallest piece of code that should reproduce the error. I have found out that in function templateForName is container undefined in this case.

I need to dynamically create views in my custom ContainerView.

Activity

  1. Myslik commented on Apr 30, 2013

    @Myslik
    ContributorAuthor

    I have looked inside your view tests and you are defining the container when creating the view. It is the preferred scenario right now?

  2. stefanpenner commented on Apr 30, 2013

    @stefanpenner
    Member

    @Myslik in most situations you should be using this.createChildView, this setups of the childView correctly.

    see https://github.com/emberjs/ember.js/blob/master/packages/ember-views/lib/views/view.js#L2058 for more details.

    That being said, we should be giving helpful deprecation warnings rather then this rather opaque error.

  3. stefanpenner commented on Apr 30, 2013

    @stefanpenner
    Member

    @Myslik this should help: ecbd0bf

  4. Myslik commented on May 1, 2013

    @Myslik
    ContributorAuthor

    Thank you, I have missed that method.

  5. ghost assigned on May 1, 2013
  6. dogawaf commented on May 1, 2013

    @dogawaf

    @stefanpenner, I don't understand how to arrange this code in order to use createChildViews...

    App.ModalView = Ember.ContainerView.extend({
        childViews: ['modalHeaderView', 'modalBodyView'],
    
        modalHeaderView: Ember.View.extend({
            templateName: 'modal/modal_header'
        }),
    
        modalBodyView: Ember.ContainerView.extend({
            currentViewBinding: 'controller.currentView'
        })
    });
    

    For now I have the error thrown in templateForNamebecause of a undefined container...

  7. stefanpenner commented on May 1, 2013

    @stefanpenner
    Member

    @dogawaf on master, there should be not error just a deprecation warning.

    @dogawaf I tried to replicate your issue @ http://jsbin.com/ucanam/21/ but was unable to. Can you continue from the jsbin, and demonstrate the issue? Just ping back on this thread once you have it... I will help you sort this out.

  8. dogawaf commented on May 2, 2013

    @dogawaf

    Hi @stefanpenner

    I have updated the jsbin. I've got the deprecation warning, and the assertion failure. http://jsbin.com/ucanam/22/
    You can see that my modal is rendered through a {{render}}. I don't know if this is relevant...

  9. stefanpenner commented on May 2, 2013

    @stefanpenner
    Member

    @dogawaf bdffb37 should fix your issue, please confirm.

  10. dogawaf commented on May 3, 2013

    @dogawaf

    Yes it did. Thanks a lot.

  11. stefanpenner commented on May 3, 2013

    @stefanpenner
    Member

    it appears that the outstanding issues for this ticket have been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions