Hi,

> > 1. 90% of the time, you'll figure out what's wrong in the process of
> > doing it -- instant help!
>
> Bingo!

Cool. :-)

> So I worked out that it is because of this:
> ...
> Though, changing to what I logically would have thought it should be
> hasn't worked

IE is not tolerant of trailing commas in object and array literals
(e.g., "[1, 2, ]" instead of "[1, 2]"), so it won't like the original
addBehavior code you quoted.  Other browsers' JavaScript parsers are
more forgiving (although technically the trailing comma is wrong in
the current version of JavaScript; Crockford and others are trying to
get it put in the next ECMAScript spec though[1], and I think they've
succeeded as of the latest 3.1 draft[2]).

[1] http://javascript.crockford.com/recommend.html
[2] http://wiki.ecmascript.org/doku.php?id=es3.1:es3.1_proposal_working_draft

So just drop the comma after the function definition:

Event.addBehavior({
        '.collapse:click' : function(e) {
                var div = this.id;
                new Effect.toggle(div + '-block','blind', {queue:
'end', duration: 0.5});
        } // <== No comma

});

The problem with the replacement code you listed is that you're
calling observe() on an array [the return value of $$()].  observe()
is a method Prototype adds to elements, not arrays.  You could get
what you were looking for via Enumerable#invoke()[3] (Enumerable is
mixed into arrays), but just deleting the comma should be all you
need.

[3] http://www.prototypejs.org/api/enumerable/invoke

HTH,
--
T.J. Crowder
tj / crowder software / com

On Dec 1, 11:39 pm, Grant Newton <[EMAIL PROTECTED]> wrote:
> > 1. 90% of the time, you'll figure out what's wrong in the process of  
> > doing it -- instant help!
>
> Bingo!
>
> So I worked out that it is because of this:
>
> Event.addBehavior({
>         '.collapse:click' : function(e) {
>                 var div = this.id;
>                 new Effect.toggle(div + '-block','blind', {queue: 'end', 
> duration:  
> 0.5});
>         },
>
> });
>
> Though, changing to what I logically would have thought it should be  
> hasn't worked:
>
>         $$('.collapse').observe('click', function() {
>                 var div = this.id;
>                 new Effect.toggle(div + '-block','blind', {queue: 'end', 
> duration:  
> 0.5});
>         });
>
> Suggestions?
>
> Grant
>
> On 01/12/2008, at 9:06 PM, T.J. Crowder wrote:
>
>
>
> > Hi Grant,
>
> >> And even after copy/paste of your code, I still get the error.
>
> > You would do; as I said, the problem isn't in the code you quoted, so
> > my changes to it don't matter other than removing an unnecessary call.
>
> >> An example of where I have it in use is:
>
> > Sorry, it's just not practical for other people to go digging around
> > the full version.  Again:  Can you create a _small, self-contained
> > page_ that demonstrates the problem.  There are two reasons for doing
> > this:  1. 90% of the time, you'll figure out what's wrong in the
> > process of doing it -- instant help!  2. If not, it gives people
> > trying to help you out a small, simple example of the problem.
> > --
> > T.J. Crowder
> > tj / crowder software / com
>
> > On Dec 1, 5:51 am, Grant Newton <[EMAIL PROTECTED]> wrote:
> >> Thanks TJ
>
> >> An example of where I have it in use is:
>
> >>        http://www.sydneycommunitycollege.com.au/courses/sport/dance
>
> >> And even after copy/paste of your code, I still get the error.
>
> >> Thanks
>
> >> Grant
>
> >> On 01/12/2008, at 4:35 PM, T.J. Crowder wrote:
>
> >>> Hi Grant,
>
> >>> You only need $() to extend elements that have not already been
> >>> extended.  $$() extends the elements it returns[1].  Also, the only
> >>> reason to call $() is if you're doing something with the return  
> >>> value,
> >>> which in the given code you're not.
>
> >>> [1]http://prototypejs.org/api/utility/dollar
>
> >>> Your code doesn't cause an error at my end in IE6 (and does hide the
> >>> relevant bits), but again, you dont need the $() call, so you can do
> >>> this instead:
>
> >>> document.observe('dom:loaded', function() {
> >>>    $$('.blockbody').invoke('hide');
> >>>    $$('.hint').invoke('hide');
> >>>    $$('.reason').invoke('hide');
> >>> });
>
> >>> The problem must lie elsewhere.  Can you create a small, self-
> >>> contained page that demonstrates the problem and poast it to Pastie?
> >>> Along the way you may figure out the problem, and if not, it'll give
> >>> the folks here something complete to help you with.
>
> >>> HTH,
> >>> --
> >>> T.J. Crowder
> >>> tj / crowder software / com
>
> >>> On Dec 1, 12:33 am, grant <[EMAIL PROTECTED]> wrote:
> >>>> Hello all
>
> >>>> I am having a little trouble with IE6 and this snippet of code:
>
> >>>>         document.observe('dom:loaded', function() {
> >>>>                 $(
> >>>>                         $$('.blockbody').invoke('hide'),
> >>>>                         $$('.hint').invoke('hide'),
> >>>>                         $$('.reason').invoke('hide')
> >>>>                 );
> >>>>         });
>
> >>>> I've done some searching to try and work out why I am receiving the
> >>>> error:
>
> >>>>         "Object doesn't support this property or method"
>
> >>>> Wiki docs suggest wrapping with $(), though I don't think I have  
> >>>> done
> >>>> that properly. Any help is much appreciated.
>
> >>>> Grant
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to