add reset event

main v0.2.0
HerrHase 1 week ago
parent 4725bf8ed5
commit b137cec475

@ -39,6 +39,9 @@
<button class="button" type="submit"> <button class="button" type="submit">
Send Send
</button> </button>
<button class="button" type="reset">
Reset
</button>
</form> </form>
</div> </div>
</div> </div>

File diff suppressed because one or more lines are too long

@ -1,6 +1,6 @@
{ {
"name": "@tiny-components/upload", "name": "@tiny-components/upload",
"version": "0.1.0", "version": "0.2.0",
"description": "Upload Field for Riotjs", "description": "Upload Field for Riotjs",
"repository": { "repository": {
"type": "git", "type": "git",

@ -5,9 +5,9 @@ import FieldUpload from './fieldUpload.riot'
riot.register('tiny-field-upload', FieldUpload) riot.register('tiny-field-upload', FieldUpload)
riot.mount('tiny-field-upload') riot.mount('tiny-field-upload')
form.addEventListener('submit', (event) => { document.querySelector('.form-html').addEventListener('submit', (event) => {
event.preventDefault() event.preventDefault()
const data = new FormData(event.target); const data = new FormData(event.target)
console.log(data) console.log(data)
}) })

@ -57,6 +57,11 @@
{ {
// getting field for getting files // getting field for getting files
this.field = this.$(this.state.TINY_FIELD_UPLOAD_FIELD) this.field = this.$(this.state.TINY_FIELD_UPLOAD_FIELD)
// getting closet form-element and add reset
this.root.closest('form').addEventListener('reset', () => {
this.reset()
})
}, },
/** /**
@ -136,6 +141,17 @@
if (this.props.max && (this.state.files.length >= this.props.max)) { if (this.props.max && (this.state.files.length >= this.props.max)) {
this.state.disabled = true this.state.disabled = true
} }
},
/**
*
*
*/
reset() {
this.state.files = []
this.validateMax()
this.update()
} }
} }

Loading…
Cancel
Save