Skip to content

Instantly share code, notes, and snippets.

@msmorgan
Forked from richardsondx/view
Created April 27, 2012 17:58
Show Gist options
  • Save msmorgan/2511337 to your computer and use it in GitHub Desktop.
Save msmorgan/2511337 to your computer and use it in GitHub Desktop.
This is what I've done
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var micropostIds = [<%= @microposts.map {|micropost| micropost.id }.join(',') %>];
$.each(micropostIds, function (index, value) {
$(".slidingDiv" + value).hide();
$(".show_hide" + value).show().click(function () {
$(".slidingDiv" + value).slideToggle();
});
});
});
</script>
<% for micropost in @microposts %>
<%= link_to image_tag('Comment.png', :mouseover => "Comment-Over.png", :class => "show_hide"), "#" %>
<div class="slidingDiv<%= micropost.id %>">
<%= render :partial => 'microposts/display', :locals => { :micropost => @micropost } %>
</div>
<a href="#" class="show_hide<%= micropost.id %>">hide</a>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment