Remove / Reset JQuery Event Handlers

Posted By Weston Ganger

When working on ajax or turbolinks websites, if your not careful with which elements you bind events to it can result in additional event handlers being attached. This means your function will run as many times you have added the event again. I has an event that is bound to the document object like so:

$(document).off('click','.my-class');
$(document).on('click','.my-class',function(){...});

Related External Links:

Article Topic:Software Development - Javascript

Date:October 13, 2015