Hi Sam (I'm guessing that's your name),
On 1/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Thank you everyone who replied! I took Jorge's advice to use the Dom
> approach, and Arnar I used your code to do this. It works like a
> charm.
Glad to hear.
> But now I want to up the ante....and instead of just having the text
> appear, I want it to appear as html, so I can have "Your <b>string</b>
> here" appear with 'string' bolded. How can I change Arnar's code
> (which I understand (yay!)) to allow me to have html show up instead
> of just text?
The reason you get the < and > characters literally is not due to Kid
(I believe) but because MochiKit is corecing the string to a dom text
node via document.createTextNode(yourstring). That involves no
xml/html parsing of the string.
Your best bet here would probably be to use innerHtml, changing the line
replaceChildNodes('infotarget', 'Your string here');
to
$('infotarget').innerHtml = 'Your <b>html</b> formatted string here';
This makes the browser parse the string as html and create the
appropriate dom nodes.
If you are creating your string in javascript (as opposed from
receiving it prebuilt from the server), you can also use MochiKit to
build the dom nodes for you - like this:
replaceChildNodes('infotarget', 'Your ', B('html'), ' formatted string here');
.. well, almost. Since <b></b> is in some circles considered
"deprecated" in favour of more semantic markup (such as <span>) the
MochiKit doesn't by default define a function called "B". You can
easily correct that though by including this line somewhere it's run
before the above code:
B = createDOMFunc('b');
See here for reference:
http://mochikit.com/doc/html/MochiKit/DOM.html#fn-createdom
Arnar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---