Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function submit(sink, data) {
if (!(this instanceof submit)) {
return new submit(sink, data)
}
this.sink = sink
this.data = data
this.id = sink.id
this.type = 'submit'
}
submit.prototype.handleEvent = function(event) {
var isValid = event.target.tagName === 'FORM' && event.type === 'submit'
if (! isValid) return;
event.preventDefault()
var values = serialize(event.currentTarget, { hash: true });
var data = extend(values, this.data);
if (typeof this.sink === 'function') {
this.sink(data)
} else {
this.sink.write(data)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.