1
0
postdoc/app/javascript/controllers/clipboard_controller.js

24 lines
504 B
JavaScript
Raw Normal View History

2020-12-06 20:49:03 +01:00
// Visit The Stimulus Handbook for more details
// https://stimulusjs.org/handbook/introduction
//
// This example controller works with specially annotated HTML like:
//
// <div data-controller="hello">
// <h1 data-target="hello.output"></h1>
// </div>
import { Controller } from "stimulus"
export default class extends Controller {
static targets = [ "source" ]
connect() {
}
copy(event) {
event.preventDefault();
this.sourceTarget.select()
document.execCommand("copy")
}
}