jqueryjquery-migrate

jQuery.fn.scroll() event shorthand is deprecated


I'm upgrading jQuery in my project to a recent version 3.4.1. I set up jquery-migrate and look in the browser console to see things I should modify. Among others it reads jQuery.fn.scroll() event shorthand is deprecated.

My code is simple: divBody.scroll();.

The documentation says: To trigger the event manually, apply .scroll() without an argument:. I firmly believe this is what I'm doing. Why does migrate still complain?


Solution

  • It appears that the documentation has not been updated to reflect the deprecation. See the warning messages for the jQuery Migrate Plugin (specifically the event shorthand deprecations).

    Per the solution provided there, the following code should work, removing the deprecation warning:

    divBody.trigger("scroll");