mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Destroys the previous ClipboardAction instance whenever a new click is triggered
This commit is contained in:
parent
3610bfa08c
commit
076e3b8a64
@ -14,8 +14,8 @@ class Clipboard extends Emitter {
|
|||||||
constructor(selector) {
|
constructor(selector) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
let delegate = new Delegate(document.body);
|
this.delegate = new Delegate(document.body);
|
||||||
delegate.on('click', selector, (e) => this.initialize(e));
|
this.delegate.on('click', selector, (e) => this.initialize(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,7 +23,11 @@ class Clipboard extends Emitter {
|
|||||||
* @param {Event} e
|
* @param {Event} e
|
||||||
*/
|
*/
|
||||||
initialize(e) {
|
initialize(e) {
|
||||||
new ClipboardAction({
|
if (this.clipboardAction) {
|
||||||
|
this.clipboardAction = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.clipboardAction = new ClipboardAction({
|
||||||
action : e.target.getAttribute('data-action'),
|
action : e.target.getAttribute('data-action'),
|
||||||
target : e.target.getAttribute('data-target'),
|
target : e.target.getAttribute('data-target'),
|
||||||
text : e.target.getAttribute('data-text'),
|
text : e.target.getAttribute('data-text'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user