How to pass javascript/jQuery settings from page to page in rails?
Posted
by
aronchick
on Stack Overflow
See other posts from Stack Overflow
or by aronchick
Published on 2011-01-16T03:01:51Z
Indexed on
2011/01/16
5:54 UTC
Read the original article
Hit count: 194
When doing javascript manipulation of what's visible, how does one pass that from page to page (ideally in Rails)?
For example, let's say I have the following simple jQuery code:
<% link_to "Next Page", report_path %>
<div class="clickable-div" style="background-color:#FFFFFF;"></div>
<script>
$('.clickable-div').click(function () {
var color = $(this).css("background-color", "#000000");
});
</script>
If it's not clear, the code is just supposed to change the color of the div based on whether or not it has been clicked. Regardless, there's also a link on the page that allows someone to go to the reporting page. What's a way to pass the state of the div to the action call?
EDIT
It seems unnecessary to do it in a session - am I wrong? This is just something from one page to the next, I couldn't care less anywhere else on the site.
EDIT 2
To confirm, Rails needs to have access to the action that occurred in Javascript on the previous page.
© Stack Overflow or respective owner