Discard event from document: jquery

Binding a function to a document for all elements that have a SearchableCol class

jQuery(document).on("click", ".SearchableCol", nwcsClickFunc);

I'm trying to use two methods to untie, nothing works.

jQuery(document).unbind("click", nwcsClickFunc);
jQuery(".SearchableCol").unbind("click");

Help is needed to untie the event from the document.

+4
source share
3 answers

Try

jQuery(document).off("click", ".SearchableCol", nwcsClickFunc);

or use event handlers with a name extension

jQuery(document).on("click.myevent", ".SearchableCol", nwcsClickFunc);

then

jQuery(document).off("click.myevent", ".SearchableCol");
+8
source
jQuery(document).off("click", ".SearchableCol", nwcsClickFunc);
+3
source

using:

$(".SearchableCol").unbind('click',nwcsClickFunc);

or

$(document).off('click','.SearchableCol',nwcsClickFunc);
+1
source

Source: https://habr.com/ru/post/1527868/


All Articles