Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > image/row cloning with attached behaviors. clicking cloned image, executes methods on original.

Reply
Thread Tools

image/row cloning with attached behaviors. clicking cloned image, executes methods on original.

 
 
sonic
Guest
Posts: n/a
 
      08-16-2005
Hello,

I am cloning a table row which contains images that have behaviors
attached to them as well as onclick events.

The problem is that the cloned row seems to be executing the
behavior/events on the original rows image. I overwrote the onclick as
well as attached a behavior to the image in cloned row, but events such
as onmouseover execute now on both images when the duplicate is mouse
overed.

here is how i clone the row:

var oldRow = t.rows[0];
var newRow = oldRow.cloneNode( true );

I know that i can re-create the new row/image from scratch, however, I
would like to be able to use the cloning technique because of the way
the original is crated ( on the server ) with alot of properties/events
that would need to be re-created. The only thing i need to change on
the cloned row is the id's of most elements. I got everything to work
correctly accept for one last issue explained in teh first half of this
post.

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      08-16-2005
sonic wrote:
> Hello,
>
> I am cloning a table row which contains images that have behaviors
> attached to them as well as onclick events.
>
> The problem is that the cloned row seems to be executing the
> behavior/events on the original rows image. I overwrote the onclick as
> well as attached a behavior to the image in cloned row, but events such
> as onmouseover execute now on both images when the duplicate is mouse
> overed.
>
> here is how i clone the row:
>
> var oldRow = t.rows[0];
> var newRow = oldRow.cloneNode( true );


now is to know how you made your roll-over function on images ...
(if it works on name (or id) of images
that will want to roll 2 (or more) same nammed images )

You know you can use css to do a roll-over ?
(automaticaly pre-loaded image and no possibility to confuse)
simple css roll-over
http://perso.wanadoo.fr/stephane.mor..._etats_css.htm

--
Stephane Moriaux et son [moins] vieux Mac
 
Reply With Quote
 
 
 
 
sonic
Guest
Posts: n/a
 
      08-17-2005
the rollover is a small part of the attached behaviors.
what would be the difference if it was done by name vs id in the
context of my original question ?

 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      08-17-2005
sonic wrote:
> the rollover is a small part of the attached behaviors.
> what would be the difference if it was done by name vs id in the
> context of my original question ?


<cite>
but events such
as onmouseover execute now on both images when the duplicate is mouse
overed.
</cite>

I understood :
- you clone a row with images
- images have a rollover

I supose you appendChild somewhere this clone (and its images)

So we get 2 teams of images with same ids or names
if you rollover the image nammed 'img_1'
wich one of both 'img_1' the browser has to roll ?

--
Stephane Moriaux et son [moins] vieux Mac
 
Reply With Quote
 
sonic
Guest
Posts: n/a
 
      08-17-2005
hi,
that is correct,
however after cloning, i override the image id's in the cloned row.
i also attempted to override names, but those don't seem to get
overriden !
id's appear with new names when i write out the new rows innerHTML

 
Reply With Quote
 
sancha
Guest
Posts: n/a
 
      08-17-2005
use 'this' it might work
forget abt id or name if you are using IE

i clone a row and then do getElementsByName('firstrow') and guess what
i have 2 rows with the same name... oh yeah i did set the id,name of
the cloned row differently but as u now IE is special. btw i also
found out if u have an element without an name but an id. and do
getElementsByName it will fethch the element with the id but no name
@#$@#$
and getElementsByName is case insensitive as well (

 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      08-17-2005
sonic wrote:
> hi,
> that is correct,
> however after cloning, i override the image id's in the cloned row.
> i also attempted to override names, but those don't seem to get
> overriden !
> id's appear with new names when i write out the new rows innerHTML


did you also correct the mouse-envent calling ?


simple JS rollover without name of image (nor id of link) :
(to see if it corrects pblems with clones ?)

function roll(obj,newImg) {
obj = obj.getElementsByTagName('IMG')[0].src
obj = newImg;
}

<a href="foo_1.htm" id="lk_1"
onmouseover="roll(this,'pict_1o.jpg');"
onmouseoout="roll(this,'pict_1.jpg');">
<img src="pict_1.jpg">
</a>
<a href="foo_2.htm" id="lk_2"
onmouseover="roll(this,'pict_2o.jpg');"
onmouseoout="roll(this,'pict_2.jpg');">
<img src="pict_2.jpg">
</a>

and much beter using pre-loaded images

and once more : use css roll-overs

--
Stephane Moriaux et son [moins] vieux Mac
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows XP freezes when USB mouse/keyboard are attached but not when a serial set is attached John Dalberg Computer Support 4 06-17-2007 09:27 AM
Session management when browser window is cloned mikharakiri_nospaum@yahoo.com Java 11 04-26-2006 07:11 PM
dvd menu on cloned disc Pavel Ferenc DVD Video 0 11-11-2005 05:53 PM
I want to be able to access the internet by opening my browser and not right clicking and then clicking connect. James Johnson Computer Support 1 05-15-2004 03:40 AM
Virtual Access Interface not cloned from Template Matthew Melbourne Cisco 0 11-11-2003 11:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57