JQuery Waypoints throws Uncaught error: handler option not passed to Waypoint constructor

I am using waypoint version 3.1.1 with jquery version also using shortcut with this as my calling code

$('.navWrap').waypoint('sticky', {
  direction: 'up',
});

      

But I get the error "Problem: No handler passed to waypoint constructor" and the waypoint does not fire.

What am I doing wrong?

+3


source to share


1 answer


As the error indicates, waypoints require a "handler" option, which defines a callback function when scrolling to a waypoint element:

$('.navWrap').waypoint('sticky', {
    direction: 'up',
    handler: function(direction) {
        alert(direction);
    }
});

      

You can also try doing this using the new no-framework paradigm:



var sticky = new Waypoint.Sticky({
  element: $('.navWrap')[0]
});

      

See docs here:

https://github.com/imakewebthings/waypoints

0


source







All Articles