ampersand-filereader-input-view
A view module for returning metadata via callback using browser FileReader. Works well with ampersand-form-view.
It does the following:
- Returns an object via
callback
prop/method with metadata for file selected.
install
npm install ampersand-filereader-input-view
example
The only required attributes are name and type. Everything else is optional (even the callback.)
var InputView = require('ampersand-filereader-input-view');
var field = new FileReaderInputView({
name: 'file',
template:
callback: function (fileInputView, data) {}
label: 'File',
placeholder: 'file',
el: document.getElementByID('field'),
validClass: 'input-valid',
type: 'file',
invalidClass: 'input-invalid',
requiredMessage: 'This field is required.',
parent: someViewInstance
});
document.querySelector('form').appendChild(field.el);
browser support
credits
Created by @gdibble.
license
MIT
» npmjs.com/package/ampersand-filereader-input-view