[英]Using clipboard.js how to destroy all its object before creating new one?
Using clipboard something like this in my controller 在我的控制器中使用这样的剪贴板
function myController() {
new Clipboard('.btn', {
text: function(trigger) { return 'some dynamic text'; }
}
}
Now the issue is everytime the controller is loaded, it creates a new object of Clipboard, is there any way I can destroy all its objects before creating new? 现在问题是每次加载控制器时,它都会创建一个剪贴板的新对象,有没有什么办法可以在创建新对象之前销毁它的所有对象? here is the link to library: https://zenorocha.github.io/clipboard.js/
这是图书馆的链接: https : //zenorocha.github.io/clipboard.js/
Just save the instance of the clipboard and erase the previous one: 只需保存剪贴板的实例并删除前一个:
var previousClipboard = null;
function myController() {
if(previousClipboard != null){
previousClipboard.destroy();
}
previousClipboard = new Clipboard('.btn', {
text: function(trigger) { return 'some dynamic text'; }
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.