Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destroy() method doesn't work to me #18

Open
TomThak opened this issue Oct 19, 2015 · 3 comments
Open

destroy() method doesn't work to me #18

TomThak opened this issue Oct 19, 2015 · 3 comments

Comments

@TomThak
Copy link

TomThak commented Oct 19, 2015

Hello,
is there any possibility to create demo with .destroy() method?

I tried to initialize the plug in on click and I would like to have off button to switch it off,
so I tried destroy() method, but it did not stop highlighting. Once I switch it on,
I cannot switch it off. I would like to have it like "higlight pen" button on my page and when you select
this tool you can highlight text. If you switch it of, it should not highlight anymore until you selet the tool again.

example:

jQuery('#textHighlightHandlerOn').click(function(e){ e.preventDefault(); hltr = new TextHighlighter(sandbox); }); jQuery('#textHighlightHandlerOff').click(function(e){ e.preventDefault(); hltr.destroy(); });

Thanks for the details!

@papadako
Copy link

Hi there,
we seem to have the same problem. We call destroy() but the events for highlighting are still triggered. Anyone have any clue about this problem (it seems that mir3z is not maintaining this project anymore...)?.

@nhulongctk10
Copy link

I also got the same problem. @@

@EstudoParaValer
Copy link

You can use a method (which I don't know if it's the most suitable), but I had the same problem and now I've managed to solve it.
The method is as follows:

"Your instance" .doHighlight = () => {};

If you prefer, before deleting, simply store the "doHighlight" function in a variable beforehand.
Thus, to restore, simply assign the content of the variable to "doHighlight".
Example:
Before:
var MyFunction = "Your instance" .doHighlight;
"Your instance" .doHighlight = () => {};

After
"Your instance" .doHighlight = MyFunction;
In Brazil, we call this "Gambiarra"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants