From what follows it will be obvious that I am not a javascript expert
but Mochikit has made it possible to do some very cool things although
I continue to have the problem outlined below.
What is the correct mochikit way of adding "onclick -->
do_something(this)" to a DOM element. What I currently (try) to do is
something like:
var s = SPAN({'onclick':'do_something(this)'},'test')
The reason I ask about this is:
1) When I do the above, the 'onclick' attribute does not show up in
the generated source. Maybe this is normal although it makes
debugging a little tricky.
2) More importantly, the above does not always work. When I use
swapDOM to replace an existing element with the SPAN above the
'onclick' isn't recognized, however when I do appendChildNodes it does
work. In situations where swapDOM doesn't work, if I do:
updateNodeAttributes(s, {'onclick':'do_something(this);'});
it does work (but never appears in generated source), I just don't
understand why when swapping the node the 'onclick' doesn't work.
I have tried using SPAN({'onclick':do_something}) -- using the
function itself and not a string, but that doesn't work and not sure
how you pick up the concept of 'this'.
Perhaps the above is completely related to (my) operator error, but I
am very interested in what is going on and the proper way to deal with
this.
Steve
X-Google-Language: ENGLISH,ASCII-7-bit
Received: by 10.54.68.11 with SMTP id q11mr167930wra;
Sun, 21 May 2006 05:35:37 -0700 (PDT)
Return-Path: <[EMAIL PROTECTED]>
Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.225])
by mx.googlegroups.com with ESMTP id v11si653750cwb.2006.05.21.05.35.36;
Sun, 21 May 2006 05:35:37 -0700 (PDT)
Received-SPF: pass (googlegroups.com: domain of [EMAIL PROTECTED] designates
64.233.184.225 as permitted sender)
DomainKey-Status: good (test mode)
Received: by wr-out-0506.google.com with SMTP id 71so480355wra
for <[email protected]>; Sun, 21 May 2006 05:35:36 -0700 (PDT)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s¾ta; d=gmail.com;
h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition;
b=ihm/Z/zXnM/lwg31hNaa1IFtWO7IzRTPRIRYbRJFzBouu1y0L9EUC99xht0vcxOOI8d6HRTEJ6jiGShK3R0O+S9WlmWd8H4I8teJz3kevBM50WqaW452eUR20UXI+jtOQOTo9LtXQgPUZuUW9pv4R9XmJWORRrTpLDqHGksBkioReceived:
by 10.54.93.16 with SMTP id q16mr100714wrb;
Sun, 21 May 2006 05:35:36 -0700 (PDT)
Received: by 10.54.98.7 with HTTP; Sun, 21 May 2006 05:35:36 -0700 (PDT)
Message-ID: <[EMAIL PROTECTED]>
Date: Sun, 21 May 2006 08:35:36 -0400
From: "Steve Zatz" <[EMAIL PROTECTED]>
To: [email protected]
Subject: onclick question
Mime-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Fromwhat follows it will be obvious that I am not a javascript expert
but Mochikit has made it possible to do some very cool things although
I continue to have the problem outlined below.
What is the correct mochikit way of adding "onclick -->
do_something(this)" to a DOM element. What I currently (try) to do is
something like:
var s = SPAN({'onclick':'do_something(this)'},'test')
The reason I ask about this is:
1) When I do the above, the 'onclick' attribute does not show up in
the generated source. Maybe this is normal although it makes
debugging a little tricky.
2) More importantly, the above does not always work. When I use
swapDOM to replace an existing element with the SPAN above the
'onclick' isn't recognized, however when I do appendChildNodes it does
work. In situations where swapDOM doesn't work, if I do:
updateNodeAttributes(s, {'onclick':'do_something(this);'});
it does work (but never appears in generated source), I just don't
understand why when swapping the node the 'onclick' doesn't work.
I have tried using SPAN({'onclick':do_something}) -- using the
function itself and not a string, but that doesn't work and not sure
how you pick up the concept of 'this'.
Perhaps the above is completely related to (my) operator error, but I
am very interested in what is going on and the proper way to deal with
this.
Steve
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---