Question

for example this code

var html = "<p>This text is <a href=#> good</a></p>";
var newNode = Builder.node('div',{className: 'test'},[html]);
$('placeholder').update(newNode);

casues the p and a tags to be shown, how do I prevent them from being escaped?

Was it helpful?

Solution

The last parameter to Builder.node is "Array, List of other nodes to be appended as children" according to the Wiki. So when you pass it a string it is treated like text.

You could use:

var a = Builder.node('div').update("<a href='#'>foo</a>")

Where the link is text or:

var a = Builder.node('div', {'class':'cool'}, 
         [Builder.node('div', {'class': 'another_div'})]
        );

And you could use just Prototypes new Element() (Available as of version 1.6).

var a = new Element('div').insert(
          new Element('div', {'class': 'inner_div'}).update("Text in the inner div")
        );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top