Placing a button inside a rendered partial that hides the partial
<%= render :partial => "list" %>
Inside this partial there is only one div. I would like to have a button in the top right corner of the div to close the div. I would like the butt开发者_运维百科on to "not render" the partial and just display the rest of the index.html.
How should I code the button in rails? It will be a small png. Thanks
in your layout
<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>
精彩评论