Skip to:
Content

BuddyPress.org

Changeset 6919


Ignore:
Timestamp:
04/18/2013 12:43:13 AM (11 years ago)
Author:
boonebgorges
Message:

Use event delegation for AJAX buttons in Groups and Members directories

In r6635, BP's use of the deprecated jQuery.live() was switched to jQuery.on().
However, the change was not made in a way that preserved the behavior of live()
with respect to items added to the DOM dynamically, as per an AJAX callback.
We replicate that behavior by using jQuery.on() delegation on a persistent
parent element. That way, group directory buttons (Join/Leave) and member
directory buttons (Add Friend/Remove Friend) continue to work even when the
view is refreshed via AJAX, as in pagination or reordering.

Fixes #4931

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.7/bp-themes/bp-default/_inc/global.js

    r6687 r6919  
    888888
    889889    /* Add / Remove friendship buttons */
    890     jq(".friendship-button a").on('click', function() {
     890    jq('#members-dir-list').on('click', '.friendship-button a', function() {
    891891        jq(this).parent().addClass('loading');
    892892        var fid = jq(this).attr('id');
     
    938938    /** Group Join / Leave Buttons **************************************/
    939939
    940     jq(".group-button a").on('click', function() {
     940    jq('#groups-dir-list').on('click', '.group-button a', function() {
    941941        var gid = jq(this).parent().attr('id');
    942942        gid = gid.split('-');
Note: See TracChangeset for help on using the changeset viewer.