From c38b72bca62a2d9cad008d5cfe398f676a0db2f2 Mon Sep 17 00:00:00 2001 From: mrsfy Date: Mon, 25 Jul 2016 16:52:17 +0300 Subject: [PATCH] Fixed bug for multiple instances. --- cytoscape-clipboard.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cytoscape-clipboard.js b/cytoscape-clipboard.js index 85f955a..1850d90 100644 --- a/cytoscape-clipboard.js +++ b/cytoscape-clipboard.js @@ -10,7 +10,6 @@ var _instance; - var initialized = false; cytoscape('core', 'clipboard', function (opts) { var cy = this; @@ -21,6 +20,14 @@ $.extend(true, options, opts); + function getScratch() { + if (!cy.scratch("_clipboard")) { + cy.scratch("_clipboard", { }); + + } + return cy.scratch("_clipboard"); + } + var counter = 0; function guid() { @@ -75,10 +82,10 @@ } - if (!initialized) { - initialized = true; + if (!getScratch().isInitialized) { + getScratch().isInitialized = true; var ur; - var clipboard = {}; + var clipboard = {}; _instance = { copy: function (eles, _id) {