473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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.

Aug 16 '05 #1
7 2695
ASM
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
Aug 16 '05 #2
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 ?

Aug 17 '05 #3
ASM
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
Aug 17 '05 #4

Chances are is due to the absolute addressing, the IDs, instead, either,
rename the ids on the cloned one, or, do not use IDs in the source, and
use 'this' or just node/sibling addressing instead.
Danny

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Aug 17 '05 #5
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

Aug 17 '05 #6
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 :((

Aug 17 '05 #7
ASM
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
Aug 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Csaba Gabor | last post by:
Is there any way to determine the pixel height and width of an original image? Specifically, If I have <IMG id=myImg src="pic.jpg" height=200 width=300> can I figure out what the original size...
2
by: Robin S. | last post by:
This is an "Add product" form. The user will enter a ProductNo (catalog number), select a Product Class (from cascading combo boxes) and then click a button to create the product. When a...
0
by: meh | last post by:
Greetings all; Got some questions about cloning a treenode.... In this example: private void button4_Click(object sender, System.EventArgs e) { TreeNode lastNode = treeView1.Nodes....
8
by: kurotsuke | last post by:
Hi, I need to clone a class (called NodeAbstract) that I derived from TreeNode. I need to clone it to support drag and drop on the treeview. I tried to use the MemberWiseClone (in my own...
0
by: ryanr | last post by:
I've run into a problem with a recursive algorithm. Basically, it grabs a tree, and creates premutations based off it. For example: Suppose you have you sell shoes in two colors (Black,...
2
by: genojoe | last post by:
I want to transfer a copy of a RichTextBox to a thread but can't seem to find the right code. Something like the following seems logical but is not valid code. I have tried variations and did Web...
2
by: Janis Papanagnou | last post by:
I want to use the 'cloneNode(true)' method to duplicate table rows with all its subnodes. Cloning the complete tree is very handy but I must be cautious because of the unique IDs and names that...
1
by: colmkav | last post by:
Hi, what is the main reason why cloning is done to tables in Access VBA code? regards Colm
3
by: raylopez99 | last post by:
The "C# Cookbook" (O'Reilly / Jay Hilyard), section 3.26, is on deep cloning versus shallow cloning. The scanned pages of this book are found here: http://www.sendspace.com/file/mjyocg (Word...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.