Skip to main content

Bug Tracker

Side navigation

#4596 closed feature (wontfix)

Opened April 27, 2009 05:07PM UTC

Closed June 06, 2011 06:46PM UTC

find function including the results of filter?

Reported by: kazar Owned by:
Priority: low Milestone: 1.next
Component: traversing Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description

Hi,

Just an idea - I often find myself doing something like:

$(this).filter(".a-class").add($(this).find(".a-class"));

I (personally) find this a bit clunky. Was wondering if it was sensible to perhaps make find include the results of a filter over the set of elements, so i would just have to do this:

$(this).find(".a-class", { withset: true });

(or something along those lines), just seems cleaner to me, especially because I seem to end up doing that first bit of code a lot.

Cheers

Attachments (0)
Change History (16)

Changed June 12, 2010 06:36PM UTC by dmethvin comment:1

component: unfiledtraversing

Changed October 24, 2010 04:50PM UTC by rwaldron comment:2

keywords: → needsreview
milestone: 1.41.5
priority: triviallow

Changed April 16, 2011 09:51PM UTC by john comment:3

milestone: → 1.next
status: newopen

Let's consider this for 1.7, I've often wanted a method similar to this - perhaps something like .findFilter().

Changed May 22, 2011 07:27PM UTC by john comment:4

keywords: needsreviewneedsreview,1.7-discuss

Nominating ticket for 1.7 discussion.

Changed May 22, 2011 10:00PM UTC by dmethvin comment:5

+1, Useful, small, and easy to document.

Changed May 22, 2011 10:30PM UTC by rwaldron comment:6

description: Hi, \ \ Just an idea - I often find myself doing something like: \ \ $(this).filter(".a-class").add($(this).find(".a-class")); \ \ I (personally) find this a bit clunky. Was wondering if it was sensible to perhaps make find include the results of a filter over the set of elements, so i would just have to do this: \ \ $(this).find(".a-class", { withset: true }); \ \ (or something along those lines), just seems cleaner to me, especially because I seem to end up doing that first bit of code a lot. \ \ CheersHi,\ \ Just an idea - I often find myself doing something like:\ \ $(this).filter(".a-class").add($(this).find(".a-class"));\ \ I (personally) find this a bit clunky. Was wondering if it was sensible to perhaps make find include the results of a filter over the set of elements, so i would just have to do this:\ \ $(this).find(".a-class", { withset: true });\ \ (or something along those lines), just seems cleaner to me, especially because I seem to end up doing that first bit of code a lot.\ \ Cheers

-1, can be easily accomplished with existing api; proposal is confusing

Changed May 22, 2011 11:43PM UTC by jaubourg comment:7

+0, If it's small, why not, if not then meh.

Changed May 23, 2011 01:46AM UTC by ajpiano comment:8

description: Hi,\ \ Just an idea - I often find myself doing something like:\ \ $(this).filter(".a-class").add($(this).find(".a-class"));\ \ I (personally) find this a bit clunky. Was wondering if it was sensible to perhaps make find include the results of a filter over the set of elements, so i would just have to do this:\ \ $(this).find(".a-class", { withset: true });\ \ (or something along those lines), just seems cleaner to me, especially because I seem to end up doing that first bit of code a lot.\ \ CheersHi, \ \ Just an idea - I often find myself doing something like: \ \ $(this).filter(".a-class").add($(this).find(".a-class")); \ \ I (personally) find this a bit clunky. Was wondering if it was sensible to perhaps make find include the results of a filter over the set of elements, so i would just have to do this: \ \ $(this).find(".a-class", { withset: true }); \ \ (or something along those lines), just seems cleaner to me, especially because I seem to end up doing that first bit of code a lot. \ \ Cheers

+0, I think this is kind of confusing as "findFilter," can we come up with a better name, at least?

Changed May 23, 2011 02:46AM UTC by timmywil comment:9

description: Hi, \ \ Just an idea - I often find myself doing something like: \ \ $(this).filter(".a-class").add($(this).find(".a-class")); \ \ I (personally) find this a bit clunky. Was wondering if it was sensible to perhaps make find include the results of a filter over the set of elements, so i would just have to do this: \ \ $(this).find(".a-class", { withset: true }); \ \ (or something along those lines), just seems cleaner to me, especially because I seem to end up doing that first bit of code a lot. \ \ CheersHi,\ \ Just an idea - I often find myself doing something like:\ \ $(this).filter(".a-class").add($(this).find(".a-class"));\ \ I (personally) find this a bit clunky. Was wondering if it was sensible to perhaps make find include the results of a filter over the set of elements, so i would just have to do this:\ \ $(this).find(".a-class", { withset: true });\ \ (or something along those lines), just seems cleaner to me, especially because I seem to end up doing that first bit of code a lot.\ \ Cheers

+0, possibly as a new function to make the API clear.

Changed May 23, 2011 03:21PM UTC by danheberden comment:10

-1, i think adding more options just muddles up the api - it's easily possible with the current API and a plugin could be written to make $.fn.findAndAdd or something

Changed June 03, 2011 01:09PM UTC by john comment:11

+1, I find myself doing this (or equivalent) all the time. I don't agree with the API proposed (it should be much simpler, like .filterFind()).

Changed June 03, 2011 02:11PM UTC by scottgonzalez comment:12

+1, I really don't like the proposed API, but I'm in favor of a new method with this functionality

Changed June 04, 2011 10:14PM UTC by addyosmani comment:13

+0

Changed June 06, 2011 03:36PM UTC by jzaefferer comment:14

-1, too similar to #4446: .find("a.class").andSelf(".a-class")

Changed June 06, 2011 03:38PM UTC by cowboy comment:15

-1, No need for a separate method or option, as this could be accomplished with #4446 $(this).find(selector).andSelf(selector);

Changed June 06, 2011 06:46PM UTC by rwaldron comment:16

description: Hi,\ \ Just an idea - I often find myself doing something like:\ \ $(this).filter(".a-class").add($(this).find(".a-class"));\ \ I (personally) find this a bit clunky. Was wondering if it was sensible to perhaps make find include the results of a filter over the set of elements, so i would just have to do this:\ \ $(this).find(".a-class", { withset: true });\ \ (or something along those lines), just seems cleaner to me, especially because I seem to end up doing that first bit of code a lot.\ \ CheersHi, \ \ Just an idea - I often find myself doing something like: \ \ $(this).filter(".a-class").add($(this).find(".a-class")); \ \ I (personally) find this a bit clunky. Was wondering if it was sensible to perhaps make find include the results of a filter over the set of elements, so i would just have to do this: \ \ $(this).find(".a-class", { withset: true }); \ \ (or something along those lines), just seems cleaner to me, especially because I seem to end up doing that first bit of code a lot. \ \ Cheers
keywords: needsreview,1.7-discuss
resolution: → wontfix
status: openclosed