Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
need help with event.observe
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ecb  
View profile  
 More options Jul 22 2008, 10:00 pm
From: ecb <s...@coyoteorganics.com>
Date: Tue, 22 Jul 2008 19:00:24 -0700 (PDT)
Local: Tues, Jul 22 2008 10:00 pm
Subject: need help with event.observe
Hi,

I need help with the following problem.

<code>
var xspanid = .. whatever ...
Event.observe(xspanid, "click",
this.deleteitem.bindAsEventListener(this, xspanid));
</code>

the code above works (I've included two lines that I think are
equivalent and both work the same, just  .  The problem I'm having is
that deleteitem is only bound to the most recent span to which I
attach this event, instead of to all of them.

on the other hand, if I run a loop on all the spans together and
attach the events within that loop, then they all work.  But only want
to attach an observer once, at the moment the span is created.

The difference in the loop is that one is cycling through dom element,
such as :
<code>
X = $$('span.xspan'); // gets a collection of span elements I'm
interested in
X.each(function(item) {
// Event.observe(item, "click",
this.deleteitem.bindAsEventListener(item, item.id));

}.bind(this));\

</code>

so "item" is not the same sort of thing as "xspanid" above.  Thus, I
tried it like this as well:

<code>
Event.observe($(xspanid), "click",
this.deleteitem.bindAsEventListener(this, xspanid));
</code>

with exactly the same results.  Only that last span that gets passed
through here gets an observer attached to it.

I really don't understand why it works just as well, to the extent
that it does, with either an element id or the whole element as the
first argument.  But that's another question.

Thanks in advance for any help.

Best

ecb


 
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.
T.J. Crowder  
View profile  
 More options Jul 23 2008, 12:17 am
From: "T.J. Crowder" <t...@crowdersoftware.com>
Date: Tue, 22 Jul 2008 21:17:24 -0700 (PDT)
Local: Wed, Jul 23 2008 12:17 am
Subject: Re: need help with event.observe
Hi,

This group is essentially closed to new posts.  Use the new, better-
named, hopefully-spam-free group for Prototype and script.aculo.us:

   http://groups.google.com/group/prototype-scriptaculous/

   prototype-scriptaculous@googlegroups.com

Hope this helps.
--
T.J. Crowder
tj / crowder software / com

On Jul 23, 3:00 am, ecb <s...@coyoteorganics.com> wrote:


 
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.
ecb  
View profile  
 More options Jul 23 2008, 1:19 am
From: ecb <s...@coyoteorganics.com>
Date: Tue, 22 Jul 2008 22:19:22 -0700 (PDT)
Local: Wed, Jul 23 2008 1:19 am
Subject: Re: need help with event.observe
ok. thanks.

On Jul 22, 9:17 pm, "T.J. Crowder" <t...@crowdersoftware.com> wrote:


 
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.
End of messages
« Back to Discussions « Newer topic     Older topic »