隐藏DIV [滑轨] [英] Hide a DIV [Rails]

查看:140
本文介绍了隐藏DIV [滑轨]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

隐藏一个DIV将在Javascript很容易,但有一定的Rails-Y方式做到这一点?我能想到的一些方法通过从局部(.erb)调用,当然JavaScript,为做到这一点,但我preFER不写任何JavaScript的。可能吗?

Hiding a DIV would be easy enough in Javascript, but is there some Rails-y way to do it? I can think of some ways to do it by calling Javascript from a partial (.erb), of course, but I'd prefer not to write any Javascript at all. Possible?

编辑:的页面加载,我想隐藏的DIV (当然,上)Ajax调用,所以我在其中的一个渲染:更新

The page is loaded and I would like to hide the DIV after (well, on) an Ajax call, so I'm in one of those render :update blocks.

推荐答案

或者,就在你的观点:

有关的一类指定的div:

For a class-specified div:

<%= link_to_function "Toggle", "$('.some_div').toggle()" %>

有关一个ID指定的div:

For an ID-specified div:

<%= link_to_function "Toggle", "$('#some_div').toggle()" %>

(注意井号)

(notice the hash-mark)

补充周期类具体的股利和哈希标识特定的div

Added period to class specific div and hash to id specific div

这篇关于隐藏DIV [滑轨]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆