I have a div, and I want it to be a link to other page. Usually we do it like this link_to link.
<% for post in @posts %>
<%= link_to "Post", post %> # -> or <%= link_to(post) %>
<% end %>
But i need to whole div to be a link with js. So, i did:
<% for post in @posts %>
<div class="post-on-main-page-<%= div_count %>" >
<script>
$(".post-on-main-page-<%= div_count %>").click(function(){
window.location.href = "<%= link_to(post) %>";
});
</script>
</div>
<% end %>
But i doesn't work.
I need to window.location.href = "<%= link_to(post) %>"; where post is a parameter, to give me a link to that post.
So how I can make this to work?
divand use that value to do your redirecting?