[Dojo-interest] Set CSS class

Daniel daniel.carrera at zmsl.com
Mon Dec 17 16:02:49 UTC 2007


THANK YOU!!!  Yay it works!

You wouldn't believe how many HOURS I've spent banging my head against 
the wall with this problem.

It would be nice if dojo.addClass did this. It looks easy enough:

dojo.addClass = function(obj, className) {
	obj.className += className;
}


Cheers,
Daniel.

Tom Trenka wrote:
> "class" and "style" are not real attributes, which is why you can't set them
> that way in IE.  To set the class on a node, do this:
> 
> node.className="Foo";
> 
> for style text:
> 
> node.cssText="styletexthere";
> 
> trt
> 
> 
> Daniel Carrera-2 wrote:
>> Thanks.
>>
>> Sigh...  Some times IE makes me want to cry. I've been trying to get the 
>> stupid thing to work for hours. The IE debugger *says* that the object 
>> has the class "Foo", but visually it doesn't have any of the attributes 
>> of the class (background, text-alignment, box size) and the result is 
>> quite unusable (because the box is tiny and it's supposed to be big).
>>
>> I don't know what to do anymore. IE only seems to read the CSS when it's 
>> not a class that was added later by me. And I really really can't 
>> refactor the CSS in a way that doesn't require assigning a class to the 
>> div in question.
>>
>> I was hoping that Dojo's addClass function would work because Dojo 
>> widgets don't seem to have this problem. But it didn't help. :-(
>>
>> I'll come back to this tomorrow.
>>
>> Thanks for the help.
>>
>> Daniel.
>>
>>
>> Dustin Machi wrote:
>>> http://redesign.dojotoolkit.org/?q=jsdoc/dojo/HEAD/object/dojo.addClass
>>>
>>> Daniel wrote:
>>>> Hello,
>>>>
>>>> I'm having trouble with Internet Explorer. It doesn't like this
>>>> construct:
>>>>
>>>> domObj.setAttribute("class", "Foo");
>>>>
>>>> I believe that there is a dojo method to assign a class to an DOM 
>>>> object, but I've been looking all over for it and can't find it. Could 
>>>> someone tell me how to assign a class to an object? On Google I found 
>>>> 'dojo.html.setClass' but apparently that doesn't exist anymore.
>>>>
>>>> Help.
>>>>
>>>> Daniel.
>>>> _______________________________________________
>>>> FAQ: http://dojotoolkit.org/support/faq
>>>> Book: http://dojotoolkit.org/docs/book
>>>> Forums: http://dojotoolkit.org/forum
>>>> Dojo-interest at dojotoolkit.org
>>>> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>>>>
>>> _______________________________________________
>>> FAQ: http://dojotoolkit.org/support/faq
>>> Book: http://dojotoolkit.org/docs/book
>>> Forums: http://dojotoolkit.org/forum
>>> Dojo-interest at dojotoolkit.org
>>> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>>>
>> _______________________________________________
>> FAQ: http://dojotoolkit.org/support/faq
>> Book: http://dojotoolkit.org/docs/book
>> Forums: http://dojotoolkit.org/forum
>> Dojo-interest at dojotoolkit.org
>> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>>
>>
> 



More information about the Dojo-interest mailing list