Skip to content

Instantly share code, notes, and snippets.

@songjiz
Created January 30, 2021 02:44
Show Gist options
  • Save songjiz/4ab5348fa16581f20471f18624558022 to your computer and use it in GitHub Desktop.
Save songjiz/4ab5348fa16581f20471f18624558022 to your computer and use it in GitHub Desktop.
export default class extends ApplicationController {
print() {
window.print()
}
scrollToTop() {
window.scrollTo({ top: 0, behavior: "smooth" })
}
confirm(event) {
const { message } = event.target.closest("[data-message]").dataset
const result = window.confirm(message)
if (!result) event.preventDefault()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment