views:

260

answers:

1

How can I use RJS to modify CSS elements on a page? I'm looking to do modify the margin of a div to add a "margin-top: 2.8em;"

How can I access this with RJS or should i use something like

page << "document.getElementById('super-wrap').style.margin-top='2.8em;';"

Though this doesn't work.

Thanks

A: 

Found it:

#some.html.erb
page.call "set_style", "super-wrap", "some_css_class"

#css
.some_css_class {
    margin-top: 2.8em;
}

#appliction.js
function set_style(element, class_name) {
    new Element.ClassNames(element).set(class_name);
}

Now I need to make it ease in... at the moment it just dumps itself in there.

holden