Google Groups Home
Help | Sign in
Message from discussion delegating in jquery: problems
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Sudara  
View profile
 More options 27 Mar, 17:30
From: Sudara <markswilli...@gmail.com>
Date: Thu, 27 Mar 2008 10:30:05 -0700 (PDT)
Local: Thurs 27 Mar 2008 17:30
Subject: delegating in jquery: problems
Hey there!

I'm SUPER excited about event delegation, and I'm giving it a whirl
with jquery, using behaviours.

So, I've got something simmering like so

Track = $.klass({

  onclick: $.delegate({
    '.track_link' : function(e){ this.toggleOptions(e) },
    '.play_link' : function(e){ this.togglePlay(e) }
  })

  // then, i define toggleOptions and togglePlay and so on...

});

Basically, I'm creating a Track behavior. A track has some links in
it, including .track_link and .play_link. Ok, but I get stuck:

1. "e" doesn't seem to be the event, it seems to be the target - is
this correct or am I smoking crack? I don't really need the event (i
don't think), but in the example on the danwebb blog, you explicitly
pass e.target.

2. In these two functions that I'm calling (like toggleOptions) if I
return false in the method, the event continues to bubble. Is this
right? I can change it to be

return this.toggleOptions(e)

with toggleOptions or even manually return false, in which case then
the event stops bubbling.

and this brings me to...

3. For some odd reason, I can only match against 1 selector. So, in
the above example, I can match either .track_link OR .play_link,
basically, whichever comes first.

HALP!

I'm very excited by what I *could* be doing once I get this working,
but something seems fishy here (else I'm having a bad coding day.)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google