List Info

Thread: MochiKit 1.3 - find immediate parent




MochiKit 1.3 - find immediate parent
user name
2007-12-18 08:58:25
Hi:

I'm using MochiKit with TurboGears and am trying to find how
I can get
a reference to the immediate parent of a node in the DOM.  I
see that
getFirstParentByTagAndClassName is available in 1.4, but I'm
using
1.3.?? in TurboGears.  Is there a relatively easy way to get
a
reference to it?

Alternatively, what I'm really trying to do is to swap out a
node with
some new html.  I've tried using the swapDOM method, but it
seems like
I need to create a DOM node for the second parameter of the
method.
But, I have raw HTML in a string variable that I'm trying to
swap in.
Needless to say, I'm quite new to this.  Is there a way to
convert my
raw HTML into a DOM node tree?

-Jim

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "MochiKit" group.
To post to this group, send email to mochikitgooglegroups.com
To unsubscribe from this group, send email to
mochikit-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: MochiKit 1.3 - find immediate parent
country flaguser name
Denmark
2007-12-18 09:19:05
Hi Jim,

> I'm using MochiKit with TurboGears and am trying to
find how I can get
> a reference to the immediate parent of a node in the
DOM.  I see that
> getFirstParentByTagAndClassName is available in 1.4,
but I'm using
> 1.3.?? in TurboGears.  Is there a relatively easy way
to get a
> reference to it?

node.parentNode would be a good choice - has nothing to do
with MochiKit 
and everything to do with DOM 

> Alternatively, what I'm really trying to do is to swap
out a node with
> some new html.  I've tried using the swapDOM method,
but it seems like
> I need to create a DOM node for the second parameter of
the method.
> But, I have raw HTML in a string variable that I'm
trying to swap in.
> Needless to say, I'm quite new to this.  Is there a way
to convert my
> raw HTML into a DOM node tree?

Well, you actually still cannot, because you will need to
use innerHTML 
and then you will not only replace this immediate child node
but also 
potentials siblings. But if it has no siblings, you can
use:

  node.parentNode.innerHTML =
"<b>foo</b>".



-- 
Morten Barklund - Head of Development - TBWAPLAY

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "MochiKit" group.
To post to this group, send email to mochikitgooglegroups.com
To unsubscribe from this group, send email to
mochikit-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: MochiKit 1.3 - find immediate parent
user name
2007-12-18 09:25:27


On Dec 18, 9:19 am, Morten Barklund <mor...barklund.dk> wrote:
> Hi Jim,
>
> > I'm using MochiKit with TurboGears and am trying
to find how I can get
> > a reference to the immediate parent of a node in
the DOM.  I see that
> > getFirstParentByTagAndClassName is available in
1.4, but I'm using
> > 1.3.?? in TurboGears.  Is there a relatively easy
way to get a
> > reference to it?
>
> node.parentNode would be a good choice - has nothing to
do with MochiKit
> and everything to do with DOM 
>
> > Alternatively, what I'm really trying to do is to
swap out a node with
> > some new html.  I've tried using the swapDOM
method, but it seems like
> > I need to create a DOM node for the second
parameter of the method.
> > But, I have raw HTML in a string variable that I'm
trying to swap in.
> > Needless to say, I'm quite new to this.  Is there
a way to convert my
> > raw HTML into a DOM node tree?
>
> Well, you actually still cannot, because you will need
to use innerHTML
> and then you will not only replace this immediate child
node but also
> potentials siblings. But if it has no siblings, you can
use:
>
>   node.parentNode.innerHTML =
"<b>foo</b>".
>
> 
>
> --
> Morten Barklund - Head of Development - TBWAPLAY

Thanks Morten, thats exactly what I needed.  I don't know
why I
couldn't find that googling for it.

-Jim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "MochiKit" group.
To post to this group, send email to mochikitgooglegroups.com
To unsubscribe from this group, send email to
mochikit-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )