Skip to content

Instantly share code, notes, and snippets.

@rainerborene
rainerborene / dom.js
Last active February 17, 2022 14:54
rails-ujs is a past thing. Here is how you can accomplish almost the same behaviour with Stimulus and Hotwire.
export function reduceToParams(elements) {
return elements.reduce((hash, node) => Object.assign(hash, { [node.name]: node.value }), {})
}
export function stopEverything(e) {
e.preventDefault()
e.stopPropagation()
e.stopImmediatePropagation()
}