1

Is it possible to unbind a .on "update" function?

Example:

price_slider_element.noUiSlider.on('update', function( values, handle ) {

      // Code
});
Michael
  • 383
  • 5
  • 19

1 Answers1

2

If you want to unbind all the handlers for the event you can use off('event') however that will remove all the event handlers for that event.

If you want to remove a specific one, you would want to make the callback a named function, or stored in a variable, and then use off('event', methodName) and then only that particular handler will be removed.

function thing () {}

$(selector).on('click', thing);
//removes all click event handlers
$(selector).off('click');
//removes just one
$(selector).off('click', thing);
Taplar
  • 24,246
  • 4
  • 18
  • 33
  • Is it possible to have syntax similar to $(element).unbind("click").bind("click") ? – Michael May 03 '18 at 18:47
  • unbind (and bind) has been deprecated, and most likely is just a wrapper around off, so yes you should be able to chain like that I would believe. – Taplar May 03 '18 at 18:48