jQuery error TypeError: $.event.handle is undefined

14,400

The function has been deprecated: http://jquery.com/upgrade-guide/1.9/#other-undocumented-properties-and-methods

You can use $.event.dispatch instead.

In addition or alternatively to using the dispatch function you can add the Migrate plugin, http://blog.jquery.com/2013/05/01/jquery-migrate-1-2-0-released/, which will add back in $.event.handle so you able to fix the code without breaking the application.

Share:
14,400

Related videos on Youtube

justnajm
Author by

justnajm

(Web + Mobile) >>> (Apps / Games) <<< (Analyst + Designer + Developer) Currently looking for a position in a competitive environment that effectively utilizes my analytic, interpersonal, leadership and organizational skills to conceive and achieve solutions. The solutions which help the organization grow. Large bugs bugs me, small bites, smaller comes in dream, smallest haunt, tiny hunt me, tinier curse me, tiniest plan... because I swipe them

Updated on June 06, 2022

Comments

  • justnajm
    justnajm 6 months

    I am using latest jQuery for jQuery.masonry its throwing following error: on line 47 in jquery-1.9.1.min.js

    TypeError: $.event.handle is undefined
    

    if any one is having same error ?

    MyCode:

    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/jquery-1.9.1.min.js"></script>
    <script language="javascript" src="http://masonry.desandro.com/jquery.masonry.min.js"></script>
    <script src="http://masonry.desandro.com/js/jquery.infinitescroll.min.js"></script>
    <script>
      $(function(){
        var $container = $('#content');
        $container.imagesLoaded(function(){
          $container.masonry({
            itemSelector: '.post',
            isAnimated: true
          });
        });
        $container.infinitescroll({
          navSelector  : '.wp-pagenavi',    // selector for the paged navigation 
          nextSelector : '.wp-pagenavi a',  // selector for the NEXT link (to page 2)
          itemSelector : '.post',     // selector for all items you'll retrieve
          loading: {
              finishedMsg: 'No more pages to load.',
              img: 'http://i.imgur.com/6RMhx.gif'
            }
          },
          // trigger Masonry as a callback
          function( newElements ) {
            // hide new items while they are loading
            var $newElems = $( newElements ).css({ opacity: 0 });
            // ensure that images load before adding to masonry layout
            $newElems.imagesLoaded(function(){
              // show elems now they're ready
              $newElems.animate({ opacity: 1 });
              $container.masonry( 'appended', $newElems, true ); 
            });
          }
        );
      });
    </script>
    
  • Sushanth --
    Sushanth -- over 9 years
    How different is your code from the OP's other than removing the chaining
  • Ohgodwhy
    Ohgodwhy over 9 years
    I don't know if you think that the variable doesn't return the jQuery object, but it surely does. I think you've been mislead somewhere.
  • Eric Martins
    Eric Martins over 9 years
    I have just checked this, you are all right, but it seems to turn the code really confusing
  • justnajm
    justnajm over 9 years
    Thanks @EricMartins but the issue is in dispatch event
  • Eric Martins
    Eric Martins over 9 years
    I am really sorry @justnajm , it will not happen again
  • Jodyshop
    Jodyshop over 2 years
    Awesome, after recent WordPress update to 5.5 the auto-scroll js stopped working, the error was: i.event.handle but now is after changing to i.event.dispatch issue resolved. Thank you

Related