Thread:Project:Support desk/SpecialPage extension: execute JavaScript function onclick/reply (2)

Jack,

Thank you so much for your extremely helpful guidance! I will be modeling my JavaScript file after the beautiful code in Extension:Comments.

I'd like to return the favor by pointing out a bug in your code, and providing a fix! I've used your function as a model for my own. I found that if I click the toggle link several times (>10), the toggling takes longer and longer, roughly twice as long each time. Quickly, this brings my browser to its knees.

The problem is that each time the  function is called, a new jQuery event handler is created using. It is appended to the list of existing event handlers. So, for each click, JavaScript is executing, etc., and this list doubles in length with each click.

One way to fix this is to use instead of   in these two lines of code:. Although, since you are using  instead of , you may need to use   instead (see the example here).

Thanks again for your help!