Skip to content

Instantly share code, notes, and snippets.

@fr0gs
Created April 27, 2016 11:52
Show Gist options
  • Save fr0gs/b9496463d37f509ae03e65bcff65084d to your computer and use it in GitHub Desktop.
Save fr0gs/b9496463d37f509ae03e65bcff65084d to your computer and use it in GitHub Desktop.
import Ember from 'ember';
import FileField from 'ember-uploader/file-field';
var AttachmentFileUploadComponent;
AttachmentFileUploadComponent = FileField.extend({
multiple: true,
attributeBindings: ["capture", "accept"],
accept: "accept='image//*'",
capture: "camera",
changedFiles: Ember.observer('files', function() {
var files;
files = this.get('files');
if (!Ember.isEmpty(files)) {
this.sendAction('filesChanged', files);
return this.rerender();
}
})
});
export default AttachmentFileUploadComponent;
<p>
This uploader uses the Ember-Upload library
</p>
<div class="attachment-file-upload">
{{ attachment-file-upload filesChanged='filesChanged' }}
</div>
<br><br>
<h3>Here the jQuery try to clean HTML5 raw file upload</h3>
<form>
<input id="file" type="file" accept="image//*" capture="camera">
</form>
<button id="clear" {{action "reset"}}>
Clear File input
</button>
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
reset: function(){
Ember.$('#file').wrap('<form>').closest('form').get(0).reset();
Ember.$('#file').unwrap();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment