开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜