【问题标题】:Placing a button inside a rendered partial that hides the partial将按钮放置在隐藏部分的渲染部分内
【发布时间】:2011-09-24 10:00:48
【问题描述】:
<%= render :partial => "list" %>

在这个部分里面只有一个 div。我想在 div 的右上角有一个按钮来关闭 div。我希望按钮“不呈现”部分内容,只显示 index.html 的其余部分。

我应该如何在 rails 中对按钮进行编码?这将是一个小png。谢谢

【问题讨论】:

  • 您使用的是什么版本的 Rails?如果您利用新功能,实际执行方式会因版本而异

标签: ruby-on-rails ruby html render partial


【解决方案1】:

在你的布局中

<html>
<head>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js", "home.js" %>    
</head>

home.js

$(document).ready(function() {

$('#close-it').live('click', function() {
$('#list').hide();
});

});

_list.html.erb

<div id="list">

<%= image_tag("button.png", :id => "close-it") %>

</div>

【讨论】:

    猜你喜欢
    • 2013-06-23
    • 1970-01-01
    • 1970-01-01
    • 2022-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多