[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread Richard D. Worth
On Wed, Nov 5, 2008 at 5:29 PM, Richard D. Worth <[EMAIL PROTECTED]> wrote:

>
> On Wed, Nov 5, 2008 at 3:29 PM, Jared Toporek <[EMAIL PROTECTED]> wrote:
>
>> I hate to barge in on this discussion with something unrelated, but how
>> long does it take for something to post? I've sent 2 posts in the last 30
>> minutes and they are not appearing.  Any idea what I might be doing wrong?
>
>
> The forum is moderated. Your first post(s) are read to make sure they
> aren't spam. After that, they should go right through.
>

That is, after you've been cleared, any future posts should go through
without moderation.

- Richard


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread Richard D. Worth
On Wed, Nov 5, 2008 at 3:29 PM, Jared Toporek <[EMAIL PROTECTED]> wrote:

> I hate to barge in on this discussion with something unrelated, but how
> long does it take for something to post? I've sent 2 posts in the last 30
> minutes and they are not appearing.  Any idea what I might be doing wrong?


The forum is moderated. Your first post(s) are read to make sure they aren't
spam. After that, they should go right through.

- Richard


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread Jared Toporek
I hate to barge in on this discussion with something unrelated, but how long
does it take for something to post? I've sent 2 posts in the last 30 minutes
and they are not appearing.  Any idea what I might be doing wrong?

On Wed, Nov 5, 2008 at 2:24 PM, Jeffrey Kretz <[EMAIL PROTECTED]> wrote:

>
> Heh.  I like that -- the Code Jihad.
>
> I agree 100% about failing silently being a BAD THING(tm).
>
> However, our disagreement involves what constitutes a fail.
>
> The only thing we've been trying to say is, an empty result set is only a
> fail under certain circumstances.
>
> To define an empty result set is a fail EVERY TIME is to limit the
> underlying system.
>
> Going back to the SQL analogy -- I have a data layer that performs a delete
> like this:
>
> DELETE FROM Table WHERE PrimaryKey = @KeyValue
> SELECT @RowCount = @@ROWCOUNT
>
> The app that calls the delete function will get a return value of how many
> rows were deleted.
>
> Maybe 0 rows is a fail, maybe it isn't.  It depends on what I'm trying to
> do.
>
> I have a choice to fail the program after the delete.
>
> It would be wrong to require a SQL Exception thrown on every case of 0 rows
> deleted.
>
> Savvy?
> JK
>
>
> -Original Message-
> From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of brian
> Sent: Wednesday, November 05, 2008 11:24 AM
> To: jQuery (English)
> Subject: [jQuery] Re: Can I make jquery not fail silently??
>
>
>
> I have a personal jihad against apps that fail silently.
>
> My jihad listens to no reason.
>
> Sure, they have valid points that make sense from the viewpoints they
> hold.  I don't share their viewpoints.  OK?
>
> Can we lighten up now?
>
>
>
> On Nov 5, 1:13 pm, ricardobeat <[EMAIL PROTECTED]> wrote:
> > That 'religious' bit is a bit offensive don't you think? There are
> > good reasons for failing silently as Mike, Richard and Jeffrey have
> > pointed out. The fact you don't accept/understand them doesn't make
> > their (and mine) opinions less empirical.
> >
> > - ricardo
> >
> > On Nov 5, 5:10 pm, brian <[EMAIL PROTECTED]> wrote:
> >
> > > > Now $('#non-existing-id').fail().toggle() will fail,
> > > > but will work if it's not empty.
> >
> > > That's actually right on the money.  Thanks.
> >
> > > //Still thinks fail silently on id queries is insane, but knows a
> > > religious argument when he sees one.
>
>


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread Jeffrey Kretz

Heh.  I like that -- the Code Jihad.

I agree 100% about failing silently being a BAD THING(tm).

However, our disagreement involves what constitutes a fail.

The only thing we've been trying to say is, an empty result set is only a
fail under certain circumstances.

To define an empty result set is a fail EVERY TIME is to limit the
underlying system.

Going back to the SQL analogy -- I have a data layer that performs a delete
like this:

DELETE FROM Table WHERE PrimaryKey = @KeyValue
SELECT @RowCount = @@ROWCOUNT

The app that calls the delete function will get a return value of how many
rows were deleted.

Maybe 0 rows is a fail, maybe it isn't.  It depends on what I'm trying to
do.

I have a choice to fail the program after the delete.

It would be wrong to require a SQL Exception thrown on every case of 0 rows
deleted.

Savvy?
JK


-Original Message-
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of brian
Sent: Wednesday, November 05, 2008 11:24 AM
To: jQuery (English)
Subject: [jQuery] Re: Can I make jquery not fail silently??



I have a personal jihad against apps that fail silently.

My jihad listens to no reason.

Sure, they have valid points that make sense from the viewpoints they
hold.  I don't share their viewpoints.  OK?

Can we lighten up now?



On Nov 5, 1:13 pm, ricardobeat <[EMAIL PROTECTED]> wrote:
> That 'religious' bit is a bit offensive don't you think? There are
> good reasons for failing silently as Mike, Richard and Jeffrey have
> pointed out. The fact you don't accept/understand them doesn't make
> their (and mine) opinions less empirical.
>
> - ricardo
>
> On Nov 5, 5:10 pm, brian <[EMAIL PROTECTED]> wrote:
>
> > > Now $('#non-existing-id').fail().toggle() will fail,
> > > but will work if it's not empty.
>
> > That's actually right on the money.  Thanks.
>
> > //Still thinks fail silently on id queries is insane, but knows a
> > religious argument when he sees one.



[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread Eric Martin

brian,

> Can we lighten up now?

This is, by far, the most friendly, relaxed technical group of people
you are going to find on the Internet. I think you might be taking it
a little too personal.

If you want to add something in your application that makes it behave
in a certain way, there is nothing stopping you. To suggest that it is
a design flaw or something wrong with jQuery is invalid, regardless of
your personal crusades ;)

A few lines of code and you have exactly what you want...but there
have been plenty of valid reasons as to why what you suggest will
never be part of "core" jQuery.

-Eric

On Nov 5, 11:23 am, brian <[EMAIL PROTECTED]> wrote:
> I have a personal jihad against apps that fail silently.
>
> My jihad listens to no reason.
>
> Sure, they have valid points that make sense from the viewpoints they
> hold.  I don't share their viewpoints.  OK?
>
> Can we lighten up now?
>
> On Nov 5, 1:13 pm, ricardobeat <[EMAIL PROTECTED]> wrote:
>
> > That 'religious' bit is a bit offensive don't you think? There are
> > good reasons for failing silently as Mike, Richard and Jeffrey have
> > pointed out. The fact you don't accept/understand them doesn't make
> > their (and mine) opinions less empirical.
>
> > - ricardo
>
> > On Nov 5, 5:10 pm, brian <[EMAIL PROTECTED]> wrote:
>
> > > > Now $('#non-existing-id').fail().toggle() will fail,
> > > > but will work if it's not empty.
>
> > > That's actually right on the money.  Thanks.
>
> > > //Still thinks fail silently on id queries is insane, but knows a
> > > religious argument when he sees one.


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread brian


I have a personal jihad against apps that fail silently.

My jihad listens to no reason.

Sure, they have valid points that make sense from the viewpoints they
hold.  I don't share their viewpoints.  OK?

Can we lighten up now?



On Nov 5, 1:13 pm, ricardobeat <[EMAIL PROTECTED]> wrote:
> That 'religious' bit is a bit offensive don't you think? There are
> good reasons for failing silently as Mike, Richard and Jeffrey have
> pointed out. The fact you don't accept/understand them doesn't make
> their (and mine) opinions less empirical.
>
> - ricardo
>
> On Nov 5, 5:10 pm, brian <[EMAIL PROTECTED]> wrote:
>
> > > Now $('#non-existing-id').fail().toggle() will fail,
> > > but will work if it's not empty.
>
> > That's actually right on the money.  Thanks.
>
> > //Still thinks fail silently on id queries is insane, but knows a
> > religious argument when he sees one.


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread Brandon Aaron
On Wed, Nov 5, 2008 at 1:10 PM, brian <[EMAIL PROTECTED]>wrote:

>
>
> > Now $('#non-existing-id').fail().toggle() will fail,
> > but will work if it's not empty.
>
> That's actually right on the money.  Thanks.
>
> //Still thinks fail silently on id queries is insane, but knows a
> religious argument when he sees one.


Hmmm ... you don't expect your CSS queries to throw an error if they don't
match an element do you? It'd be silly if it did. Then you'd need
a separate style sheet for each page instead of making good use of reusing
styles. Same goes for jQuery code. Matching zero or more elements is a
corner stone of being able to progressively enhance your web site/app with
unobtrusive javascript.

--
Brandon Aaron


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread ricardobeat

That 'religious' bit is a bit offensive don't you think? There are
good reasons for failing silently as Mike, Richard and Jeffrey have
pointed out. The fact you don't accept/understand them doesn't make
their (and mine) opinions less empirical.

- ricardo

On Nov 5, 5:10 pm, brian <[EMAIL PROTECTED]> wrote:
> > Now $('#non-existing-id').fail().toggle() will fail,
> > but will work if it's not empty.
>
> That's actually right on the money.  Thanks.
>
> //Still thinks fail silently on id queries is insane, but knows a
> religious argument when he sees one.


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread ricardobeat

oops, missed a line:

jQuery.oldfind = jQuery.find;
jQuery.find = function(t,con){
var f = jQuery.oldfind(t,con);
if (f.length == 0) throw('Empty query');
return f;
}


On Nov 5, 5:10 pm, ricardobeat <[EMAIL PROTECTED]> wrote:
> Hey Brian, try this:
>
> jQuery.oldfind = jQuery.find;
> jQuery.find = function(t,con){
>     var f = jQuery.oldfind(t,con);
>     if (f.length == 0) throw('Empty query');
>
> }
>
> cheers,
> - ricardo
>
> On Nov 5, 1:08 pm, 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?
>
> > I'm going to still think of this as a huge design flaw.
>
> > There needs to be a way to specify that it should fail on empty
> > results.  /s for strict or whatever.
>
> > This post is for 1) bitching purposes and 2) indexing purposes so that
> > future searchers find definitive proof that jquery fails silently and
> > that this is not considered a bug, despite obvious appearances.


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread brian


> Now $('#non-existing-id').fail().toggle() will fail,
> but will work if it's not empty.

That's actually right on the money.  Thanks.

//Still thinks fail silently on id queries is insane, but knows a
religious argument when he sees one.


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread ricardobeat

Hey Brian, try this:

jQuery.oldfind = jQuery.find;
jQuery.find = function(t,con){
var f = jQuery.oldfind(t,con);
if (f.length == 0) throw('Empty query');
}

cheers,
- ricardo

On Nov 5, 1:08 pm, 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?
>
> I'm going to still think of this as a huge design flaw.
>
> There needs to be a way to specify that it should fail on empty
> results.  /s for strict or whatever.
>
> This post is for 1) bitching purposes and 2) indexing purposes so that
> future searchers find definitive proof that jquery fails silently and
> that this is not considered a bug, despite obvious appearances.


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread Balazs Endresz

You can still write a simple plugin:

jQuery.fn.fail=function(){ return this.length ? this : null; }

Now $('#non-existing-id').fail().toggle() will fail,
but will work if it's not empty.

Consider this for example:
$('#non-existing-id').add('.anotherClass');
if it failed you cannot add other elements to the empty set
and you can't even write a plugin like this one above.

On Nov 5, 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?
>
> I'm going to still think of this as a huge design flaw.
>
> There needs to be a way to specify that it should fail on empty
> results.  /s for strict or whatever.
>
> This post is for 1) bitching purposes and 2) indexing purposes so that
> future searchers find definitive proof that jquery fails silently and
> that this is not considered a bug, despite obvious appearances.


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread Mike Alsup

> 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


I agree 100% with Richard.

One of the defining design characteristics of jQuery is how it
embodies implicit iteration.  So I can write this:

$('div').hide();

to hide all the divs on the page.  It doesn't matter if there are zero
divs or 100, they are all hidden.  Of course if I have a typo in my
code and execute something like this:

$('divv').hide();

no divs will be hidden.  But that does not make this a design flaw.
It makes it a typo.

Mike





[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread Jeffrey Kretz

Richard is exactly correct IMO.

The separation of HTML and Javascript allows you do write more general
javascript in attached scripts that can be applied to any page.

$('img.ihover').hover( /* Do stuff */ );

Any pages with image class="ihover" will get the hover function.

Nothing will happen on pages with NO images that fit that criteria.

At any time you MUST have a result, you can do something like this:

var imgs = $('img.ihover');
if (!imgs.length)
{
   alert('No hover images found!');
}

It leaves it up to the developer to decide which selections are required and
which aren’t.

This isn't a flaw at all, it is part-and-parcel to the jquery philosophy:

1. Grab some elements
2. Do something to them.

JK




From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Richard D. Worth
Sent: Wednesday, November 05, 2008 8:22 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Can I make jquery not fail silently??


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



[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread Richard D. Worth
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


[jQuery] Re: Can I make jquery not fail silently??

2008-11-05 Thread brian


> 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?

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

There needs to be a way to specify that it should fail on empty
results.  /s for strict or whatever.

This post is for 1) bitching purposes and 2) indexing purposes so that
future searchers find definitive proof that jquery fails silently and
that this is not considered a bug, despite obvious appearances.


[jQuery] Re: Can I make jquery not fail silently??

2008-11-04 Thread Mike Alsup

> And currently it's also the only way to get an empty jQuery object, as
> an empty selector will return 'document'.

You can get an empty jQuery object like this:

var $empty = $([]);



[jQuery] Re: Can I make jquery not fail silently??

2008-11-04 Thread ricardobeat

And currently it's also the only way to get an empty jQuery object, as
an empty selector will return 'document'.

I thought that the plus sign would always concatenate if it's used
after a string. Just tested it and I can't make it evaluate as NaN,
only with "string"+(+var). Are you missing something in that code?

You can always add a check:

if (!this.length) alert('I failed, I'm empty!!')

On Nov 4, 6:47 pm, Mike Alsup <[EMAIL PROTECTED]> wrote:
> > Is there some way to tell jQuery to actually throw errors instead of
> > failing silently?
>
> It's not a failure to run a query and find nothing - that's a
> perfectly valid use case.


[jQuery] Re: Can I make jquery not fail silently??

2008-11-04 Thread Mike Alsup

> Is there some way to tell jQuery to actually throw errors instead of
> failing silently?

It's not a failure to run a query and find nothing - that's a
perfectly valid use case.