Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove event handler used by .ajaxStop

Tags:

jquery

If I attach an event handler using .ajaxStop like this:

$(document).ajaxStop(function() {
    //Some code
});

How do I remove that event handler?

like image 326
e-zero Avatar asked Apr 23 '13 05:04

e-zero


2 Answers

Try unbinding it, like so:

$(document).ajaxStop(function () {
    $(this).unbind("ajaxStop");
    //Some code
});

It's how I've been doing it.

like image 129
Matt Finucane Avatar answered Nov 15 '22 00:11

Matt Finucane


use .off()

Remove an event handler.

$("#elementID").off()

this removes all event handler from the selected element

like image 3
bipen Avatar answered Nov 15 '22 00:11

bipen