IMO, this is bad practice.
$(element).insert('<div></div>');
-- Sent from my Palm Prē
david wrote:
Hi All,
This is not the original question, but to insert elements in the DOM,
you should do:
$('myContent').innerHTML='<div ...... </div>'
It's faster in execution than creating an element with a new.Element a
set each needed property.
--
david
On 7 déc, 12:00, "Alex McAuley" <[email protected]>
wrote:
> There is a known bug in IE8 regarding new Element and adding the class toit
> in the scope...
>
> To overcome it simply use addClassName('My-Class'); after or instead of the
> scope
>
> Alex Mcauleyhttp://www.thevacancymarket.com
>
> ----- Original Message -----
> From: "ColinFine" <[email protected]>
> To: "Prototype & script.aculo.us"
> <[email protected]>
> Sent: Monday, December 07, 2009 10:53 AM
> Subject: [Proto-Scripty] Re: document.write() vs Element/appendChild()
>
> On Dec 4, 10:36 pm, fma <[email protected]> wrote:
> > Ok, I found something...
>
> > If I look at the HTML tree in the IE debugger, on the left panel I
> > can't see any 'class' attribute. However, it does appear on the right
> > panel (called Attributs), with the correct value. But IE does not
> > seems to use it. I found that I can add an attribute to the div in the
> > left panel. So I tried to add an attribute named 'class', and I set
> > its value: this fixes the problem, and IE can apply the CSS!!!
>
> > Then, I tried something else... I used the old-style to build the DOM
> > tree:
>
> > this.content = document.createElement('div');
> > Element.extend(this.content);
> > this.content.setAttribute('id', this._name + "_content");
> > this.content.setAttribute('class', "fullContent");
> > document.body.appendChild(this.content);
>
> I don't know if this is relevant to the problem, but you don't need to
> use 'setAttribute' for built-in attributes of HTML element:
>
> this.content.id = this._name + "_content";
>
> avoids an unnecessary function call.
>
> For the DOM attribute 'class', the Javascript binding requires you to
> use 'className', because 'class' is a reserved word in Javascript:
>
> this.content.class = "fullContent";
>
> (or, using a Prototype method)
> this.content.addClassName('fullContent');
> This is not quite the same, because if you already have a class on the
> element, this will add the new class, whereas the simple assignment
> will replace it. But since you have just created the element, there is
> no difference.
>
> > instead of the new-style:
>
> > this.content = new Element('div', {'id': this._name + "_content",
> > 'class': "fullContent"});
>
> > and it worked!!!
>
> > At first, I didn't put the quotes arround the attributes names, in the
> > hash:
>
> > this.content = new Element('div', {id: this._name + "_content",
> > class: "fullContent"});
>
> > but IE does not like this syntax (it asks for an int or a string). But
> > as you can see, giving a string does not seems to work well.
>
> IE objects (correctly) to your using the Javascript reserved word
> 'class' as an object key: Firefox is more lax and lets it through.
> 'id' will work without quotes.
>
> > Am I doing something wrong with the new-style method? Or is it a known
> > issue in Prototype?
>
> I don't know. Your example seems to match that in the Prototype
> documentation. I would try it with 'className' instead of 'class' and
> see whether this works.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" 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
> athttp://groups.google.com/group/prototype-scriptaculous?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en.