1

Following function has the scroll event attached, which then triggers the custom event defined on line 5.

Line 5 seems to be causing the function to invoke twice (if removed line 4 is printed once, with line 5 its twice).

Custom event should only fire once, at the moment its twice.

 this.on(window, 'scroll', function(event){
    var win = $(window);
    if ($(document).height() - win.height() === win.scrollTop()) {
        console.log('testing 123');
         this.trigger('uiHandlRequest', { type: 'foo' });
        return false; 
        }            
   });
Deepak Rai
  • 2,163
  • 3
  • 21
  • 36
Jamie White
  • 1,560
  • 3
  • 22
  • 48

1 Answers1

0

Use 'window' instead of 'this' while triggering custom event.

this.on(window, 'scroll', function(event){
    var win = $(window);
    if ($(document).height() - win.height() === win.scrollTop()) {
        console.log('testing 123');
         window.trigger('uiHandlRequest', { type: 'foo' });
        return false; 
        }            
   });
Neeraj Verma
  • 495
  • 4
  • 17