I've written a plugin to highlight terms used to find a page. The source is also available.
My problem is, if you look at the first link's inline JavaScript, I've made a custom textPlacement function to handle the insertion of the display bar (it looks a bit like Stack Overflow's).
As you can see, I have an event handler on the button that is inserted. I have coded the removal of the bar, but I'd also like to remove the highlighting of the terms. The plugin has a method for doing this called toggleTermHighlighting()
.
How can I call that method from inside the anonymous function on the example page? Would I need to make it this.toggleTermHighlighting = function() {}
. I've tried passing in an instance of this to the first argument, but could not get it to work.
Sorry, I always seem to have a tough time with scope in JavaScript.
Does anyone know what I could do to be able to access that method from inside the anonymous function from the example page?