[buddypress-trac] [BuddyPress] #3821: Unbind selectors from tokens in jQuery

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Wed Apr 18 19:29:33 UTC 2012


#3821: Unbind selectors from tokens in jQuery
----------------------------------------+-----------------------
 Reporter:  hnla                        |       Owner:
     Type:  enhancement                 |      Status:  reopened
 Priority:  normal                      |   Milestone:  1.6
Component:  Theme                       |     Version:
 Severity:  normal                      |  Resolution:
 Keywords:  needs-testing dev-feedback  |
----------------------------------------+-----------------------
Changes (by hnla):

 * keywords:  needs-testing commit => needs-testing dev-feedback
 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 In light of issue found with favs / unfavs by Boone
 https://github.com/karmatosed/Status/issues/70

 re-opening this ticket with possible fix for problem of activity favorite
 buttons traversing back up the dom by a fixed factor
 '.parent().parent().parent()' naturally any deviation from the button
 nested at this level is going to break the functionality.

 Suggested fix is to replace .parent() with .closest('li')

 At present (line 192):
 {{{
 if ( target.hasClass('fav') || target.hasClass('unfav') ) {
         var type = target.hasClass('fav') ? 'fav' : 'unfav';
         var parent = target.parent().parent().parent();
 }}}

 replaced with:
 {{{
 if ( target.hasClass('fav') || target.hasClass('unfav') ) {
         var type = target.hasClass('fav') ? 'fav' : 'unfav';
         var parent = target.closest('li');//.parent().parent();
         var parent_id = parent.attr('id').substr( 9,
 parent.attr('id').length );
         alert(parent_id);
 }}}

 Alert() returns correct id and in testing this appears to be a workable
 change - also .closest has far less overhead than .parent() which has to
 traverse fully through the DOM to top node and retain data whereas
 .closet() halts on first match.

 There may well be issues I've not spotted though and this in this form is
 still limiting in presuming to be able to find a li element but then a
 list is the correct markup for an activity list.

 P.S This does not appear to be a fix necessarily for Status theme as that
 seems to have other issues brought to light and needs further
 investigating.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/3821#comment:12>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list