[Javascript] Create a menu in js. Understanding the workflow

MEM talofo at gmail.com
Tue Oct 27 05:45:00 CDT 2009


Thanks David. 
I've got a killing comment on this, on the php side of things:

Quoting:

"essentially what you are saying is:

1) user is presented with the basic navigation menu
2) user clicks an item and page navigates somewhere else
3) because of the item user clicked in 2) display some extra menu items

That's not a menu, it's just a navigation bar that changes slightly
depending on where you are in the site..."


So maybe my focus should not be on the click event but on the url changes?


Putting the thinks like this, should I still think on js for this job?

What do you think?


Thanks,
Márcio



> -----Original Message-----
> From: javascript-bounces at lists.evolt.org [mailto:javascript-
> bounces at lists.evolt.org] On Behalf Of David Dorward
> Sent: terça-feira, 27 de Outubro de 2009 10:18
> To: JavaScript List
> Subject: Re: [Javascript] Create a menu in js. Understanding the
> workflow
> 
> On 27 Oct 2009, at 09:39, MEM wrote:
> > I'm on my way for building a menu using javascript.
> 
> Just what the world needs.
> 
> > For this database menu I need to:
> > Have a menu that, when the user clicks:
> > a) show the child elements of that clicked parent.
> 
> In order to be accessible to non-pointing device and non-JS users, the
> menu opening element needs to be a link.
> 
> For non-JS users, this link will go to a suitable page (usually an
> index page for the menu section).
> 
> For keyboard users, it needs to be a link so it can get the focus (in
> a reliable, cross browser fashion).
> 
> Have the onclick handler change the className of the parent element (a
> list item containing the link and submenu). Use a descendent selector
> with that class name in the stylesheet to change the dislpay style of
> the submenu.
> 
> > b) change the URL.
> 
> http://www.w3.org/TR/html4/struct/links.html#h-12.2
> 
> > The server side part:
> > 1) Construct an array from a query.
> > 2) Build a ul/li List based on that array
> > 3) Print it out to the page.
> 
> All depend on the language you use and the data structure you keep the
> data in.
> 
> > The client-side part:
> > 4) I suppose I should I give to the li and ul some ids, so that we
> > can show
> > child elements only when a specific parent is clicked?
> 
> No need. You just need to identify the top of the menu. Then you can
> find ul and li elements with in it, and identify their children and
> parents.
> 
> > 5) Each time the user clicks on a menu item, the URL must change.
> > How to
> > preserve the menu estates over this url changes?
> 
> Attach a JavaScript event to the "go to page" links. Have it edit
> those links to include a serialised description of the condition of
> all the menus (e.g. in the fragment identifier). Read that information
> in the onload event.
> 
> --
> David Dorward
> http://dorward.me.uk
> 
> _______________________________________________
> Javascript mailing list
> Javascript at lists.evolt.org
> http://lists.evolt.org/mailman/listinfo/javascript




More information about the Javascript mailing list