Skip to:
Content

BuddyPress.org

Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#4969 closed enhancement (fixed)

Using Jquery .live() insteed .click()

Reported by: megainfo's profile megainfo Owned by:
Milestone: 1.8 Priority: normal
Severity: normal Version:
Component: Templates Keywords:
Cc:

Description

I suggest using jquery .live() function instead .click() in all javascript events.

.click() is not applied if the content is recovered from ajax response ( for example, if you click 'add friend' then ajax answer is an html input button 'Cancel Friendship Reques' , the .click() event is not applied to this new button).


Attachments (2)

global.js (51.0 KB) - added by megainfo 11 years ago.
Update global.js (replace all .click with .on( 'click', function(event) { )
buddypress.js (51.0 KB) - added by megainfo 11 years ago.
Update buddypress.js (replace all .click with .on( 'click', function(event) { )

Download all attachments as: .zip

Change History (10)

#1 @megainfo
11 years ago

  • Component changed from All Components to Theme

#2 @boonebgorges
11 years ago

  • Keywords reporter-feedback added

.live() is deprecated. We should be using .on() with proper event delegation.

If you find specific places in our JS where we're using .click() and need the delegation, please post them here.

#3 @megainfo
11 years ago

In file bp-legacy/js/buddypress.js

lines : 989, 1013 , 1058

Version 1, edited 11 years ago by megainfo (previous) (next) (diff)

@megainfo
11 years ago

Update global.js (replace all .click with .on( 'click', function(event) { )

@megainfo
11 years ago

Update buddypress.js (replace all .click with .on( 'click', function(event) { )

#4 @boonebgorges
11 years ago

In 6972:

Use event delegation for directory buttons in bp-legacy

This ports r6919 to bp-legacy

See #4931, #4969

#5 @boonebgorges
11 years ago

In 6973:

Use event delegation for directory buttons in bp-legacy

This ports r6919 to bp-legacy

See #4931, #4969

#6 @boonebgorges
11 years ago

In 6974:

Use event delegation to disable .pending buttons in bp-legacy

See #4969

Props megainfo

#7 @boonebgorges
11 years ago

  • Keywords reporter-feedback removed
  • Milestone changed from Awaiting Review to 1.8
  • Resolution set to fixed
  • Status changed from new to closed

So far as I can tell, the other instances you mention (1013, 1058) are for buttons/links that are never added by AJAX to the page, at least not in the context of bp-legacy. I don't think we need to go to the trouble of doing true event delegation for those items, as it would require changing some of the logic of the JS. For this reason, I'm going to mark this ticket as fixed. If you find more instances where we *need* to use delegation, please feel free to reopen this ticket with details, or open a new ticket. Thanks!

#8 @DJPaul
8 years ago

  • Component changed from Appearance - Template Parts to Templates
Note: See TracTickets for help on using tickets.