I think he's looking for a snippet handout, by the looks of the
spaghetti that he's pasted he's trying to highlight a single item in a
menu.

var activeElement = false;

$$("ul.menu li").invoke("observe", "click",
      function(e){
          var element = e.element();

          if(activeElement)
             activeElement.removeClassName("active");
           element.addClassName("active");
           activeElement = element;
      });

});

--

http://positionabsolute.net

On May 8, 5:50 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
> Hi,
>
> There are lots of code examples in the resource I pointed you to,
> particularly the unofficial wiki.  For instance, one aspect of what
> you're trying to do is hook events.  That's very thoroughly covered
> with lots of examples in the API docs[1] and on the wiki[2][3].  So
> again, have a read through and you'll be well on your way.
>
> [1]http://prototypejs.org/api/element/observe
> [2]http://proto-scripty.wikidot.com/prototype:tip-hooking-events
> [3]http://proto-scripty.wikidot.com/prototype:how-to-hooking-events
>
> Enjoy!
> --
> T.J. Crowder
> tj / crowder software / com
> Independent Software Engineer, consulting services available
>
> On May 8, 9:22 am, "z...@zanepaul.com.au" <z...@zanepaul.com.au>
> wrote:
>
> > Thanks for your reply, Im very new at this and was hoping more for
> > some code to as a starting point?
>
> > On May 8, 3:39 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
>
> > > Hi,
>
> > > Prototype can definitely help you with that.  Off the top of my head,
> > > the Prototype methods you want are Element#observe[1] (which is a
> > > convenience wrapper for Event.observe[2]) and probably
> > > Element#addClassName[3] and Element#removeClassName[4].  [OT (e.g.,
> > > not Prototype-related) you might want to use === and !== in your
> > > comparisons of object instances, rather than == and != (see the
> > > ECMAScript spec[5] for more on identity comparisons).]
>
> > > If you're just getting started with Prototype, it's _well_ worth your
> > > time having a read through the API[6] from beginning to end.  It takes
> > > about an hour, and saves you hours and hours in return.  The learn[7]
> > > page and the unofficial wiki[8] may also be useful.
>
> > > [1]http://prototypejs.org/api/element/observe
> > > [2]http://prototypejs.org/api/event/observe
> > > [3]http://prototypejs.org/api/element/addClassName
> > > [4]http://prototypejs.org/api/element/removeClassName
> > > [5]http://www.ecma-international.org/publications/standards/Ecma-262.htm
> > > [6]http://prototypejs.org/api
> > > [7]http://prototypejs.org/learn
> > > [8]http://proto-scripty.wikidot.com
>
> > > HTH!
> > > --
> > > T.J. Crowder
> > > tj / crowder software / com
> > > Independent Software Engineer, consulting services available
>
> > > On May 8, 5:53 am, "z...@zanepaul.com.au" <z...@zanepaul.com.au>
> > > wrote:
>
> > > > Im trying to get this code working in FireFox and Sarfari
>
> > > > var changeStyleColour = function () {
> > > >         var active = null, newclass = "colourActive";
> > > >         if (this.Event.addEventListener) this.Event.addEventListener
> > > > ('onUnload', function ()
> > > >                  {active = null;});
> > > >         return function (element) {
> > > >             if ((active != element) && element.className) {
> > > >                 if (active) active.className = "colourNormal";
> > > >                 element.className = newclass;
> > > >                 active = element;
> > > >             }
> > > >         };
> > > >     }();
>
> > > > Can someone please help- Hide quoted text -
>
> > > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to