Fixing broken plugin to use jQuery .on() instead of .live()

Question

Updated site to latest WordPress version (5.5.1) and unfortunately a plugin broke.

I found the SO (https://stackoverflow.com/questions/10466465/jquery-change-from-live-to-on) helpful and I know what needs to be done but I don’t know how to apply it to the existing syntax. This is a WordPress plugin (https://wordpress.org/plugins/netgo-expandablecollapsible-menu/#description) that isn’t being supported by the developer any more (couple of years now). I’d like to try and update the plugin to work with WordPress 5.5.1 instead of having to find a new plugin and update every page that used the old plugin.

The existing code is

$netgo_navigations.find("ul li").live("click", function(e) { 

and I believe I need to provide a static parent (which I have) but I don’t know how to apply it to the current syntax as shown above. My assumption was I could simply change .live to .on and it would be fixed since I thought the .find() would provide the ‘static’ parent but that doesn’t seem to be the case.

$netgo_navigations.find("ul li").on("click", function(e) { 

What else do I need to do?

0
HPWD 4 months 0 Answers 18 views 0

Leave an answer