Re: [svg-developers] node from id

2005-10-17 Thread osaka minami
well i just found

document.getElementById('myItemId').parentNode.removeChild(document.getElementById('myItemId));

that's a wired logic...

maiko

hi,

i am wondering what the quickest way is to get a node
reference out of an element accessed by
.getElementById(), let's say i want handle myItem as
a
node where myItem =
document.getElementById('myItemId') in order to
perform a removeChild() on it.

it's an easy thing when i have an event on that
object, my node is just evt.target and easy to
process.

any idea, or am i just not seeing the trees in the
forest?...







___ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail 
http://uk.messenger.yahoo.com


 Yahoo! Groups Sponsor ~-- 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/1U_rlB/TM
~- 

-
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click edit my 
membership
 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





Re: [svg-developers] node from id

2005-10-17 Thread Jonathan Watt
Hi maiko,

JavaScript isn't a strongly typed language, so you don't have to cast or
anything like that. You just use the interface you need:

var myItem = document.getElementById('myItemId');
myItem.removeChild(...);

-Jonathan

On 10/17/05, osaka minami [EMAIL PROTECTED] wrote:

 hi,

 i am wondering what the quickest way is to get a node
 reference out of an element accessed by
 .getElementById(), let's say i want handle myItem as a
 node where myItem =
 document.getElementById('myItemId') in order to
 perform a removeChild() on it.

 it's an easy thing when i have an event on that
 object, my node is just evt.target and easy to
 process.

 any idea, or am i just not seeing the trees in the
 forest?...

 thank you,

 maiko



 ___
 To help you stay safe and secure online, we've developed the all new
 Yahoo! Security Centre. http://uk.security.yahoo.com



 -
 To unsubscribe send a message to:
 [EMAIL PROTECTED]
 -or-
 visit http://groups.yahoo.com/group/svg-developers and click edit my
 membership
 
 Yahoo! Groups Links












[Non-text portions of this message have been removed]



 Yahoo! Groups Sponsor ~-- 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/1U_rlB/TM
~- 

-
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click edit my 
membership
 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 






Re: [svg-developers] node from id

2005-10-17 Thread Jonathan Watt
On 10/17/05, osaka minami [EMAIL PROTECTED] wrote:

 well i just found

 document.getElementById('myItemId').parentNode.removeChild(
 document.getElementById('myItemId));


Ah, I see. I hadn't understood it was the parent node you wanted.

that's a wired logic...

 maiko

 hi,
 
 i am wondering what the quickest way is to get a node
 reference out of an element accessed by
 .getElementById(), let's say i want handle myItem as
 a
 node where myItem =
 document.getElementById('myItemId') in order to
 perform a removeChild() on it.
 
 it's an easy thing when i have an event on that
 object, my node is just evt.target and easy to
 process.
 
 any idea, or am i just not seeing the trees in the
 forest?...
 






 ___
 Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with
 voicemail http://uk.messenger.yahoo.com



 -
 To unsubscribe send a message to:
 [EMAIL PROTECTED]
 -or-
 visit http://groups.yahoo.com/group/svg-developers and click edit my
 membership
 
 Yahoo! Groups Links











[Non-text portions of this message have been removed]



 Yahoo! Groups Sponsor ~-- 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/1U_rlB/TM
~- 

-
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click edit my 
membership
 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 






RE: [svg-developers] node from id

2005-10-17 Thread Doug Schepers
Hi, Maiko-

If you're looking for the most optimized way, do it like this:
 var myItem = doc.getElementById('myItem');
 myItem.parentNode.removeChild(myItem);

That way, you're only hitting the DOM to find the element once, instead of
twice. gEBI is a rather expensive method call, I would think, especially on
large documents (unless the implementation caches a hash table of all the
ids).

It's also shorter code, and to my mind more clear. More maintainable, too...
you only have to pass in the id once, which could get lost in a refactoring.
Ideally, you'd do this:
 var myItem = doc.getElementById('myItem');
 if ( null != myItem )
 {
   myItem.parentNode.removeChild(myItem);
 }

In case that item isn't there as expeccted, this will prevent your script
from choking.

Regards-
Doug

[EMAIL PROTECTED]
www.vectoreal.com ...for scalable solutions.
 

osaka minami wrote:
| 
| hi jonathan,
| 
| no, i want the node itself that lays under doc.gEBI('myItemId'). if
| doc.gEBI('myItem').parentNode.removeChild(doc.gEBI('myItem'))
| is the only way to go for e.g. a remove, well, ok. i just 
| wondered if there is a shorter, clear way.
| 
| thx anyway,
| 
| maiko
| 



 Yahoo! Groups Sponsor ~-- 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/1U_rlB/TM
~- 

-
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click edit my 
membership
 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 






RE: [svg-developers] node from id

2005-10-17 Thread david dailey
At 08:24 AM 10/17/2005, Doug wrote:
That way, you're only hitting the DOM to find the element once, instead of
twice. gEBI is a rather expensive method call, I would think, especially on
large documents (unless the implementation caches a hash table of all the
ids).

Interesting -- I would take this to mean that if I'm creating a whole 
bunch of stuff dynamically -- where those things might, later on, 
change, then it might be best to maintain, in parallel, a JavaScript 
array of all the things (and their attributes). It would be redundant 
in terms of storage and probably chew up some memory allocation from 
the browser, but I suppose that is relatively cheap in comparison to 
the time factor. (I have noticed that when I pack more than a few 
hundred animated things into a page the browser gets sleepy.)

Does that seem sensible?

David




 Yahoo! Groups Sponsor ~-- 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/1U_rlB/TM
~- 

-
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click edit my 
membership
 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 






Re: [svg-developers] node from id

2005-10-17 Thread Jonathan Watt
On 10/17/05, david dailey [EMAIL PROTECTED] wrote:

 At 08:24 AM 10/17/2005, Doug wrote:
 That way, you're only hitting the DOM to find the element once, instead
 of
 twice. gEBI is a rather expensive method call, I would think, especially
 on
 large documents (unless the implementation caches a hash table of all the
 ids).

 Interesting -- I would take this to mean that if I'm creating a whole
 bunch of stuff dynamically -- where those things might, later on,
 change, then it might be best to maintain, in parallel, a JavaScript
 array of all the things (and their attributes). It would be redundant
 in terms of storage and probably chew up some memory allocation from
 the browser, but I suppose that is relatively cheap in comparison to
 the time factor. (I have noticed that when I pack more than a few
 hundred animated things into a page the browser gets sleepy.)

 Does that seem sensible?

 David


Mozilla maintains a hash table. I'd imagine most other browsers would do the
same, but I could be wrong.


[Non-text portions of this message have been removed]



 Yahoo! Groups Sponsor ~-- 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/1U_rlB/TM
~- 

-
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click edit my 
membership
 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 






RE: [svg-developers] node from id

2005-10-17 Thread Doug Schepers
Hi, David-

| At 08:24 AM 10/17/2005, Doug wrote:
| That way, you're only hitting the DOM to find the element 
| once, instead 
| of twice. gEBI is a rather expensive method call, I would think, 
| especially on large documents (unless the implementation 
| caches a hash 
| table of all the ids).
| 
| Interesting -- I would take this to mean that if I'm creating 
| a whole bunch of stuff dynamically -- where those things 
| might, later on, change, then it might be best to maintain, 
| in parallel, a JavaScript array of all the things (and their 
| attributes). 

That's not what I meant (by implementation, I meant the UA, the viewer,
which might have some optimization of gEBI like that), but it is sometimes a
sound approach (depending on your use case). I have often created a
collection of objects, including the properties, metadata, and a reference
to the representative element, and used that rather than the DOM to access
properties, only updating the DOM when a rerendering is needed. I found that
it often (but not always) worked faster and was easier than dealing with the
DOM alone.


Regards-
Doug

[EMAIL PROTECTED]
www.vectoreal.com ...for scalable solutions.
 



 Yahoo! Groups Sponsor ~-- 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/1U_rlB/TM
~- 

-
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click edit my 
membership
 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 






Re: [svg-developers] node from id

2005-10-17 Thread Jeff Rafter
 Mozilla maintains a hash table. I'd imagine most other browsers would do the
 same, but I could be wrong.

Agreed. Another important point is this: because all of the 
implementations do silly stuff like maintain a hash table you can get 
into trouble with IDs. Supposedly the DTD has to be in force to know 
that an ID is an ID for getElementById-- but most implementations cheat 
and do something like //@id and Hash the results. Maybe not Moz, I am 
not sure... but this creates problems with Meta data and foreign content 
inside of your SVG.

Cheers,
Jeff Rafter


 Yahoo! Groups Sponsor ~-- 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/1U_rlB/TM
~- 

-
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click edit my 
membership
 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/