On Wed, Nov 5, 2008 at 10:08 AM, brian <[EMAIL PROTECTED]>wrote:

>
>
> > It's not a failure to run a query and find nothing - that's a
> > perfectly valid use case.
>
> I understand where you are coming from on the querying side, but
> shouldn't calling a method on an empty object fail?  How can I fade
> in...nothing?


The same way you can write a for-loop to loop over every item in an array of
integers and sum their values all together. If the array you provide to the
loop has a length 0, your sum is zero. Does that mean your loop should fail
because it went through 0 iterations?

You can read it as "Fade in any elements that match this query at this
time".


>
> I'm going to still think of this as a huge design flaw.


I have to disagree on this being a design flaw. This is one of my favorite
design features of jQuery. I often think of it like SQL. You might construct
a SQL statement like

DELETE FROM tblUsers WHERE userid = 18

or

UPDATE tblUsers SET age=5 WHERE age=4

If no records match the query, nothing happens. But that doesn't make the
query or the statement invalid. Neither do you get an exception/warning. So
the $(selector) part of jQuery is like the WHERE clause, and the method you
call is like the DELETE, or UPDATE, SET.

Wouldn't the alternative be that you would have to check the length of the
jQuery object before every single method call?

- Richard

Reply via email to