rails rjs modify style in the body to add margin
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 开发者_如何学Gocan 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
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.
精彩评论