It's difficult to say what's not working without a complete example (e.g.
what does 'data' contain). I tried this at the MochiKit demo javascript
interpreter:
s1 = SPAN('<b>foo</b> bar');
s2 = SPAN();
s2.innerHTML = '<b>foo</b> bar';
writeln(s1);
writeln(s2);
and it works as expected.
shoe
On 12/19/06, Miki <[EMAIL PROTECTED]> wrote:
Hello David,
> > I'm loading JSON using loadJSONDoc. One of the attributes of the JSON
> > document is a HTML string.
> >
> > If I try to add it as-is to the DOM (using SPAN(data.content), I see
> > the HTML tags (instead of getting the right HTML).
> > For example: If the string sent is "<b>No</b way", I'll see "<b>No</b
> > way" and not "No" in bold and then "way".
> >
> > If there a way to create a DOM object from the JSON attribute?
> Usually if you're dealing with an HTML string you should use
innerHTML. So,
> try creating the span element and setting it's innerHTML attribute to
the
> HTML string.
Thanks for the quick reply!
However it doesn't seem to work, here's my code:
function process_data(data)
{
var table = getFirstElementByTagAndClassName("table");
replaceChildNodes(table, null);
for (var i = 0; i < data.length; i++) {
var article = data[i];
description = SPAN({"class" : "full"});
description.innerHTML = article.description;
log(article.description);
var row = TR({"class" : "col1r" + (i % 2)},
TD({"class" : "time"}, article.time),
TD({"class" : "story"},
A({"href" : article.link, "class" : "item", "target" :
"full_story"},
SPAN({"class" : "title"},
article.title, " (", I(article.source), ")"),
SPAN({"class": "category"}, ""),
description
)
)
);
appendChildNodes(table, row);
}
set_message(null);
callLater(10, request_updates);
}
>
--
--- I'd give my right arm to be ambidextrous. ---
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" 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/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---