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

Can't set templateName of custom bodyViewClass of ModalPane #79

Open
pzuraq opened this issue Jul 11, 2013 · 5 comments
Open

Can't set templateName of custom bodyViewClass of ModalPane #79

pzuraq opened this issue Jul 11, 2013 · 5 comments

Comments

@pzuraq
Copy link

pzuraq commented Jul 11, 2013

I'm trying to create a custom bodyViewClass to replace the default modal body class which is too simple for my needs. Whenever I try to set a templateName, however, I get the following error:

Uncaught Error: assertion failed: You specified the templateName vehicle/price/net-reduction for <(subclass of Ember.View):ember1414>, but it did not exist.

I can use the same templateName elsewhere in the app and it displays just fine. This only comes up in the ModalPane instance. Below is the code for the ModalPane:

Bootstrap.ModalPane.popup({
  heading: 'Net Reduction',
  message: 'test',
  bodyViewClass: Ember.View.extend({
    templateName: 'vehicle/price/net-reduction'
  }),
  primary: 'Submit',
  secondary: 'Cancel',
  showBackdrop: true,
  callback: function(opts, event) {

  }
});
@bradleypriest
Copy link
Member

This is actually an issue with the removal of the default container in Ember-Core. Sadly the error coming up is a bit obtuse.

Explanation is here https://gist.github.com/stefanpenner/5627411.

There are a couple of ways of fixing it, you can pass the default container into the popup function if you have access to it from where you are calling popup.

I personally have overriden the popup method, but I have worries that it wouldn't work universally so I never contributed it back to ember-bootstrap.

Bootstrap.ModalPane.reopenClass({
  popup: function(options) {
    var modalPane, rootElement;
    if (!options) options = {};
    modalPane = this.create(options);

    if (!modalPane.container && modalPane.get("controller")) {
      modalPane.container = modalPane.get("controller").container;
    }

    rootElement = get(this, 'rootElement');
    modalPane.appendTo(rootElement);
    return modalPane;
  }
});

This is definitely something that should be fixed in ember-bootstrap, I'll have a think about it.

@pzuraq
Copy link
Author

pzuraq commented Jul 12, 2013

Ah, interesting issue. It would have taken a while for me to figure that out on my own, thanks for the help!

@pzuraq pzuraq closed this as completed Jul 12, 2013
@pzuraq
Copy link
Author

pzuraq commented Jul 12, 2013

Note: To use the fix you posted the ModalPane has to be passed a controller somehow. I ended up passing it in hash I gave to the popup method.

@flynfish
Copy link
Contributor

Any movement on this? Is ember-bootstrap going to incorporate a fix?

@dmathieu dmathieu reopened this Jul 31, 2013
@dmathieu
Copy link
Contributor

We should indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants