I have some view like this:
[CODE]
<%= form_tag( riepilogo_path, method: "post", id: "sel") do %>
<% for posti in @postis %>
<%= check_box_tag "posti_ids[]", posti.id %>
<%=h posti.numero %>
<% end %>
<%= submit_tag "OK"%>
<% end %>
I want to check checkbox and keep checked after submit and refresh or reload a page. I write jquery code like so. But it is not works.
[/CODE]
[CODE]
$(document).ready(function()
{
$("#sel").click( function(){
var chkId= [];
$("#posti_ids_:checked").each(function()
{
chkId.push( $(this).val());
a=chkId.length;
localStorage.setItem(chkId, chkId.checked);
chkId.checked = localStorage.getItem(chkId) === 'true' ?
true:false;
});
});
});
[/CODE]
What is wrong here?
Thank you!