Applying DoJo to N similar controls on a page...

Hello,

I have a page with three div regions, which for now I'm just applying
lfx.rounded to. What is the simplest way to apply this property to all
three, without having to duplicate the calls to dojo.lfx.rounded?

Here's what I have now, that does work, even though it's ugly:

dojo.addOnLoad(function(){

dojo.lfx.rounded({

tl:{
radius:1 },

bl:{
radius:20 },

tr:{
radius:20 },

br:{
radius:1 }

},

["roundMe1"]

);

dojo.lfx.rounded({

tl:{
radius:1 },

bl:{
radius:20 },

tr:{
radius:20 },

br:{
radius:1 }

},

["roundMe2"]

);

dojo.lfx.rounded({

tl:{
radius:1 },

bl:{
radius:20 },

tr:{
radius:20 },

br:{
radius:1 }

},

["roundMe3"]

);

});

Small bit of CSS:

.roundMe{

margin:20px;

padding:15px;

border:1px solid #ccc;

width:500px;

background-color:#fff;

}

The Divs are all quite similar:

content here

content here

content here

My first try was to use the same id on all three divs. I still don't
understand why that doesn't work.

Could somebody please shed some light on the best way to approach this?

Thanks in advance,

--Jon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dojotoolkit.org/pipermail/dojo-interest/attachments/20070306/a8ec...

Comments

On Tuesday 06 March 2007 15:51, Jon Jaques wrote:

var defaults = { tl: { radius:1},
bl: { radius:20},
// etc
};
dojo.lfx.rounded(defaults,["roundme1","roundme2","roundme3"]);

works, i think.

using the same ID confuses the DOM. each element can only have a unique id,
but multiple classes and/or styles ... you can alter the colors and whatnot
with classes, but applying the same corners to different id's via an array of
id's will use the same corner variable (above) ... i think dojo.lfx.rounded's
src checks isArrayLike

Yes, Beautiful, thanks! Cleaned up my code, and seems a little faster too... a fluke?

I'd tried all sorts of variations on stacking up the id names, but the one thing I missed was to put all three within the square brackets, but as soon as I saw how you'd done that, I had a Perl flashback, and realized I should have tried that sooner!

Thanks again, much appreciated!

--J

On Tuesday 06 March 2007 16:24, Jon Jaques wrote:

no. probably a design thing. first thing rounded checks is "do this once, or
a bunch of times" rather than three seperate checks ... cuts something out of
the overhead, at least. or maybe it just seems faster because it waits until
all three are done calculating before rendering the corners?

no a problem.

regards,
peter.

Back to top