Bug Tracker

Changes between Version 1 and Version 2 of Ticket #11269, comment 2


Ignore:
Timestamp:
Feb 1, 2012, 2:22:15 PM (7 years ago)
Author:
warrenparsons
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11269, comment 2

    v1 v2  
    1 Hi Dave,
    2 
    3 I think the test case didn't make the problem I'm seeing clear enough.
    4 
    5 In my real-world use case, I need to delegate because the elements in question are sometimes added to the document after page load, and it would be useful to pass in a jQuery object, as my selector is rather complex.
    6 
    7 Here is the selector I'm using:
    8 
    9 
    10 {{{
    11 var $links = $('a[href^="http"], a[rel="new-window"]').not('.colorbox, .addthis-button');
    12 }}}
    13 
    14 This would be pretty ugly to write as a pure CSS selector. Also, the API docs for the :not() selector ([http://api.jquery.com/not-selector/]) include the following:
    15 
    16 ''The .not() method will end up providing you with more readable selections than pushing complex selectors or variables into a :not() selector filter. In most cases, it is a better choice.''
    17 
    18 Being able to pass in a jQuery object rather than only a string can, in cases like this, make code more readable. It also has potential benefits when selectors are dynamically constructed, since they can be built with jQuery objects rather than put together as a string.
    19 
    20 Thanks for listening.
     1Realized I probably need to reply, rather than just add a comment.