Connecting Tech Pros Worldwide Help | Site Map

NS/Mozilla/Firefox mergeAttributes problem

 
LinkBack Thread Tools Search this Thread
  #1  
Old May 10th, 2006, 03:55 PM
mikejr83@gmail.com
Guest
 
Posts: n/a
Default NS/Mozilla/Firefox mergeAttributes problem

I've been working on a project converting some IE code to be
cross-browser complient. I've run into a little problem figuring out
how to migrate the IE specific mergeAttributes function to something
similar that is complient in NS/Mozilla/Firefox browsers.

Currently I have this basic code
row = this.insertRow(position) //I'm inserting a row into "this" table
row.mergeAttributes(this.templateRow); //here I'm basically "copying"
this template row to the newly created row
// clone all the cells from the template to the new row.
var cells = this.templateRow.childNodes;
for (var i = 0; i < cells.length; i++)
{
var cell = cells[i].cloneNode(true);
row.appendChild(cell);
}

Basically, I need to come up with a way to copy the attributes from the
the template row to the new row along with all the cells.

I've tried using the cloneNode method on the template row and assigning
the returned element to the row object that was created. This does not
work. Inside these row objects properties have been added, and if I'm
reading this code correctly, it appears that some TR level functions
have been added as well.

Thanks in advance. This has been wreaking some havoc on me for a while
and I don't currently see a solution to it. Thanks!

Mike G.


  #2  
Old May 19th, 2006, 12:15 PM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
Default Re: NS/Mozilla/Firefox mergeAttributes problem

mikejr83@gmail.com wrote:
[color=blue]
> I've been working on a project converting some IE code to be
> cross-browser complient. I've run into a little problem figuring out
> how to migrate the IE specific mergeAttributes function to something
> similar that is complient in NS/Mozilla/Firefox browsers.
>
> Currently I have this basic code
> row = this.insertRow(position) //I'm inserting a row into "this" table[/color]

For this to work, `this' would be required to be a reference to a
HTMLTableRowElement object. But that would require that code to be in
either a method of HTMLTableRowElement.prototype (which is not possible
in the IE DOM yet, and discovered recently to be not fully implemented
in the Gecko DOM yet), or a method of the HTMLTableRowElement object
itself (which is recommended against, as that object is a host object).

And do you declare `row' before you define it? If no, there is another
issue as well, as that "variable" is rather a property of the Global
Object, or a property of another globally available host object that
imposes restrictions on property write access (IE DOM); if there is an
element with ID or name `row', there will be no "variable" but a runtime
error.

So much for "cross-browser compliance".
[color=blue]
> row.mergeAttributes(this.templateRow); //here I'm basically "copying"[/color]

Since you say below that the result of the copy process is the source of
your problems, it would have been wise if you posted its source code.
[color=blue]
> this template row to the newly created row[/color]

Source code should be posted so that it still makes sense when becoming
subject to automatic word-wrapping at about column 76.
[color=blue]
> // clone all the cells from the template to the new row.
> var cells = this.templateRow.childNodes;
> for (var i = 0; i < cells.length; i++)
> {
> var cell = cells[i].cloneNode(true);
> row.appendChild(cell);
> }
>
> Basically, I need to come up with a way to copy the attributes from the
> the template row to the new row along with all the cells.[/color]

That is what Node::cloneNode() is for.
[color=blue]
> I've tried using the cloneNode method on the template row and assigning
> the returned element to the row object that was created. This does not
> work. Inside these row objects properties have been added, and if I'm
> reading this code correctly, it appears that some TR level functions
> have been added as well.[/color]

You are not making any sense. "TR level functions"? It strikes me that
your "problem" is that _you_ have augmented HTMLTableRowElement.prototype
or the corresponding HTMLTableRowElement object and now are wondering that
the copy either inherits the prototype object's or has the original object's
properties. Well, this behavior would be by design. Simply do not
augment the prototype object or the element object in the first place
then, but pass references to the corresponding element object instead.


PointedEars
--
Let us not judge others because of their religion, color or nationality.
We are all just human beings living together on this planet. (poehoe.de)
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.