Damiano
Damiano

Reputation: 11

Mootools: add HTML text to an Element

i'm using mootools.js, i have this code:

this.html.chat_title = new Element('span', {
    'id' : 'chat_title',
    html : 'this is the title'
}).inject(this.html.container);

The problem is:

span id="chat_title" html="this is the title"

as you see it doesn't put the text inside the HTML of the tag but as an attribute.

What is wrong?

Thank you so much!

Upvotes: 1

Views: 5995

Answers (3)

Ronald
Ronald

Reputation: 1815

This is because there is no Element.Properties.html setter and getter in MooTools 1.1.2. You can use the setHTML method instead:

this.html.chat_title = new Element('span', {
    'id': 'chat_title'
}).setHTML('this is the title').inject(this.html.container);

Otherwise create your own setter and getter or update to a newer version of MooTools.

Upvotes: 2

Anurag
Anurag

Reputation: 141879

Interesting.. are you using MooTools 1.1.2? I see the same on jsfiddle. html gets added as an attribute, instead of element's innerHTML.

I'd suggest you try upgrading if that is the case. 1.1.2 has been old for quite sometime now.

Upvotes: 0

Zackman
Zackman

Reputation: 314

It's valid code, so my only advice is to try downloading a full version of the MooTools Core, to make sure you're not missing a needed component (in case you downloaded using the Core Builder).

Upvotes: 1

Related Questions