Capturing information from clicks on unordered list.

1 view
Skip to first unread message

Jake

unread,
Nov 22, 2009, 1:09:13 AM11/22/09
to MooTools Users
I've hit a wall in my quest to figure out how to acquire attribute
data from an unordered list.

Here's what I'm doing:

I have a script that dynamically creates an unordered list as a
navigation menu.

The only way I can think of to get click information from this list is
if there is a specific set number of list items, and have click events
for each one.

Say a list of 10 items would mean 10 separate click event handlers.

20 list items would mean 20 event handlers.

This doesn't seem very elegant to me. But I'm a MooTools noob, so
perhaps there is a better way?

Nathan White

unread,
Nov 22, 2009, 1:17:44 AM11/22/09
to mootool...@googlegroups.com

Steve Onnis

unread,
Nov 22, 2009, 4:17:34 AM11/22/09
to mootool...@googlegroups.com
How are you creating the list elements?

I would do it like this personally

http://mooshell.net/5GsWA/6

אריה גלזר

unread,
Nov 22, 2009, 12:35:50 PM11/22/09
to mootool...@googlegroups.com
i am not sure why ou would need a specific number. can't you assign an event on item creation:
var item = new Element('li',{
'events':{
'click':function(){/*do something*/}
}
});
-----------
אריה גלזר
052-5348-561
5561

jiggliemon

unread,
Nov 22, 2009, 3:11:29 PM11/22/09
to MooTools Users
Yeah add the event to the element when it's created.

var item = new Element('li',{
'events':{
'click':function(){
return this.get('rel');
}
}
});

On Nov 22, 9:35 am, אריה גלזר <arieh.gla...@gmail.com> wrote:
> i am not sure why ou would need a specific number. can't you assign an event
> on item creation:
> var item = new Element('li',{
> 'events':{
> 'click':function(){/*do something*/}}
> });
>
> -----------
> אריה גלזר
> 052-5348-561
> 5561
>
Reply all
Reply to author
Forward
0 new messages