Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 5 years ago

Last modified 5 years ago

#4074 closed defect (bug) (fixed)

jQuery and replacement of .on() for .live()

Reported by: netweblogic Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Core Keywords:
Cc: netweblogic

Description

I know you're aware of this nuance, and that there already is compatibility with the depreciated function, but I think it's worth at least raising this so it gets done and avoid future issues.

You can get away with literally replacing .live(... with .on(... which works for me.

Alternatively, we should use the delegate() function, as that's not depreciated. Upside is it's more backwards compatible but not as simple to change.

Change History (5)

#1 @DJPaul
9 years ago

  • Milestone changed from Awaiting Review to Future Release

The whole JavaScript file is long overdue for a rewrite/audit. If someone wants to provide a patch for the issue in this ticket, that would be great. I don't think this as simple as a find/replace because we have to change the syntax slightly for delegated events.

#2 @netweblogic
9 years ago

yes, I'm very wrong actually! works first time round but not on following clicks. still easy to migrate, but a little more copy/paste involved:

$(selector).live(events, data, handler); jQuery 1.3+
$(document).on(events, selector, data, handler);
jQuery 1.7+

as per http://api.jquery.com/live/

#3 @netweblogic
9 years ago

I'd be happy to do this, but... some experience now from what I did in my plugin last week.

I would advise waiting until maybe even the next bump to a new jQuery version in WP. I've noticed a lot of users are getting js conflicts because themes and maybe even some plugins insist on using other jQuery libraries which are inevitably older than 1.7.

Since 1.7 still has backwards compatability with .live() I'd say it's not worth the headache, you'll have to do a lot less troubleshooting with users by doing this later.

#4 @tw2113
5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Unless I'm missing something somewhere, I'm not finding any instances of .live() in the BP core js files anymore. Closing.

#5 @r-a-y
5 years ago

  • Milestone Future Release deleted

Unless I'm missing something somewhere, I'm not finding any instances of .live() in the BP core js files anymore.

Well, this ticket was opened four years ago :)

Note: See TracTickets for help on using tickets.