Drop the parens around the first argument.
function foo(arg) {
return $(arg) ? true : alert('Element Does not exist'); // i commented this
out: false;
}
.......
On Tue, Jul 28, 2009 at 12:02 PM, Alex McAuley <
[email protected]> wrote:
>
> In my usual "Not enough coffee" moments i just used an If/Else instead lol
>
> Not sure why i was trying to cut code using a tenary ...
>
> We live and learn
>
> Sorry for useless post
>
>
> Alex Mcauley
> http://www.thevacancymarket.com
>
>
> ----- Original Message -----
> From: "Jeztah" <[email protected]>
> To: "Prototype & script.aculo.us" <
> [email protected]>
> Sent: Tuesday, July 28, 2009 4:51 PM
> Subject: [Proto-Scripty] ternary operators
>
>
> >
> > Afternoon guys....
> >
> > Is it possible in javascript to give out 2 answers to a tenary
> > opertor.... (doesnt make sense i know - see below)
> >
> > function foo(arg) {
> >
> > return ($(arg)) ? true : alert('Element Does not exist');false;
> >
> > }
> > ...........
> > (wrapped in window loaded function)
> >
> > foo('bazzzzzzzzzzzzz'); // doesnt exist so i want it to alert the
> > alert and return false to halt the script.......
> >
> >
> > <div id="bar"></div>
> >
> >
> >
> > Is this the right way to do it in the operator or cant it be done....
> > and no i dont want to make 2 functions i would like it in one if it
> > can be done.
> >
> > Regards
> > Alex Mcauley
> >
> > http://www.thevacancymarket.com
> > >
> >
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---