[buddypress-trac] [BuddyPress] #3279: Activity reply buttons have duplicate IDs

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Mon Jun 13 18:39:49 UTC 2011

#3279: Activity reply buttons have duplicate IDs
  Reporter:  boonebgorges  |      Owner:
      Type:  defect        |     Status:  new
  Priority:  minor         |  Milestone:  Awaiting Review
 Component:  Activity      |    Version:  1.2.8
Resolution:                |   Keywords:  needs-patch

Comment (by Dennissmolek):

 I'll take this.
 There are a few solutions to this.
 Firstly there is changing the ID field in the comments.php file created in
 the last patch(#3253)
 id="acomment-reply-<?php bp_activity_id() ?>-from-<?php
 bp_activity_comment_id() ?>"
 This would add which object it was coming from.
 The JS is set up so that ANY object clicked triggers a multitude of
 events. In this case it reads the ID of the object clicked and pulls apart
 its ID. The ID is currently acomment-reply-x. When it does so it splits
 the string by each dash, so we get an array(acomment, reply, x). Where X
 is the activity ID that we are commenting on.
 The script then pulls item [2] from the array, which in this case is the
 activity ID.

 By adding -from-y (where Y is the ID of the comment the reply button is
 being clicked) the array now looks like (acomment, reply, x, from, y) This
 does not break the JS and currently works on my testing site. Without
 pulling apart the js just to make the ID's more semantic I think this is
 the fastest and best solution.


 I think we are at a point where we could start thinking about HTML5 and
 what we could do with it. By using the data-x="" attribute we could simply
 write data-comment="" I'm writing other stuff and I have to think that
 hiding data in the ID of a element will become a faux pas when we can use
 data- much like tables were/are in the CSS era.
 link to what I'm talking about: http://ejohn.org/blog/html-5-data-
 Two things to note on this issue.
 1. If we change the code to use HTML5(which is the future) it wont
 validate on a older doctype(PS it already doesnt)
 2. The JS doesnt care, we can simply use .attr() and adjust the code
 slightly. Older browsers wont have issues with the code, they will simply
 ignore the attributes, but the JS will still run.

 What use does this have you ask? with this reply button not much, besides
 limiting the use of insane ID's and odd code. The ID could be "acomment-
 reply-1" which is semantic and valid.

 Just an idea I noticed when working on this.. Like I said, the quick fix
 is adding the little bit of code. The rest is just an idea I'm proposing..

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/3279#comment:1>
BuddyPress <http://buddypress.org/>

More information about the buddypress-trac mailing list