Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create Views dynamically #2597

Closed
Myslik opened this issue Apr 30, 2013 · 10 comments
Closed

Cannot create Views dynamically #2597

Myslik opened this issue Apr 30, 2013 · 10 comments
Assignees

Comments

@Myslik
Copy link
Contributor

Myslik commented Apr 30, 2013

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.

@Myslik
Copy link
Contributor Author

Myslik commented Apr 30, 2013

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

@stefanpenner
Copy link
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.

@stefanpenner
Copy link
Member

@Myslik this should help: ecbd0bf

@Myslik
Copy link
Contributor Author

Myslik commented May 1, 2013

Thank you, I have missed that method.

@ghost ghost assigned trek May 1, 2013
@dogawaf
Copy link

dogawaf commented May 1, 2013

@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...

@stefanpenner
Copy link
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.

@dogawaf
Copy link

dogawaf commented May 2, 2013

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...

@stefanpenner
Copy link
Member

@dogawaf bdffb37 should fix your issue, please confirm.

@dogawaf
Copy link

dogawaf commented May 3, 2013

Yes it did. Thanks a lot.

@stefanpenner
Copy link
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
Projects
None yet
Development

No branches or pull requests

4 participants