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

Unclear how to specify options #91

Closed
simenheg opened this issue Aug 24, 2015 · 10 comments
Closed

Unclear how to specify options #91

simenheg opened this issue Aug 24, 2015 · 10 comments
Assignees
Labels

Comments

@simenheg
Copy link
Contributor

It's unclear how options can be specified when instantiating a component that extends Droplet. The documentation says:

Properties that can be defined when instantiating the Ember.Component [...]

This suggests to me that options are set directly as properties on the component, like so:

Ember.Component.extend(window.Droplet, { uploadImmediately: true, [...] });

Or even:

Ember.Component.extend(window.Droplet, { options: { uploadImmediately: true }, [...] });

However I was surprised to find that these properties are overridden when the component is instantiated. I think this should be clarified in the documentation, or the behavior changed to keep option properties set on the component.

@Wildhoney Wildhoney added the bug label Aug 24, 2015
@Wildhoney Wildhoney self-assigned this Aug 24, 2015
@Wildhoney
Copy link
Owner

@simenheg Absolutely! Labelled as a bug, as options should be persisted.

@mattboldt
Copy link
Contributor

Bumping this, as I am running into the options being overridden too. Is there a version that's Ember 2.0 compatible that doesn't override custom options?

@Leooo
Copy link

Leooo commented Sep 11, 2015

+!

@Leooo
Copy link

Leooo commented Oct 9, 2015

Anyone forked a working version?

Wildhoney added a commit that referenced this issue Oct 9, 2015
@Wildhoney
Copy link
Owner

I've pushed out an emergency release of v2.0.0 to see if we can get this working. Tests will fail for the time being until we're on the right path. Please give this version a try and let me know if it behaves as expected.

@Leooo
Copy link

Leooo commented Oct 9, 2015

great thanks a lot, will test in the next day or so.

@Leooo
Copy link

Leooo commented Oct 9, 2015

No. trying to understand your use of _extends now, but this doesn't work on my side.

export default Ember.Component.extend(Droplet,{
  mimeTypes: ["application/pdf"],
  //...
});

=> $E.options.mimeTypes is still the default one

@Leooo
Copy link

Leooo commented Oct 9, 2015

easy short term fix is to set directly the option hash on the extending component, using all the keys of DEFAULT_OPTIONS:

export default Ember.Component.extend(Droplet,{
  options: {
    requestMethod: 'POST',
    maximumSize: Infinity,
    maximumValidFiles: 1,
    uploadImmediately: false,
    includeXFileSize: true,
    useArray: false,
    mimeTypes: ["application/pdf"],
    requestHeaders: {},
    requestPostData: {}
  },
  //..
};

@rupurt
Copy link
Contributor

rupurt commented Oct 9, 2015

@Leooo I can't seem to get your suggestion to work

@rupurt
Copy link
Contributor

rupurt commented Oct 9, 2015

I managed to find a solution that works. You can override the initializer and set the options after Droplet finishes the initial configuration.

export default Ember.Component.extend(Droplet, {
   init: function() {
      this._super.apply(this, arguments);
      this.set("options.uploadImmediately", true);
   }
});

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

No branches or pull requests

5 participants