Design/Implementation question on record (de)activation and view state preserving

What I want to achieve:

I have a model which has records that can either be activated or
deactivated. I want to show these records in a view. Based on the
state of a checkbox, the view should show either all activated records
or all records. Furthermore I would like to add a link to dis/enable a
record. This link should somehow submit the state of the checkbox too,
because I need to refresh the view after changing a records state. I
would like to do all this in ajax. Here is what i got so far:

## index view

<%= check_box_tag :showDisabled, :showDisabled, false, {:onclick =>
remote_function(:method => :get, :url => { :action => "index" }, :with
=> "'value='+this.checked") } %>

<div id=store_table><%= render 'store_table' %></div>

<div id="new_store_link"> <%= link_to :new_store,
new_store_path, :remote => true %> </div>
<div id="new_store_form"></div>

## store partial
<script type="text/javascript" charset="utf-8">
    a.onclick = function(){a.setAttribute('href',
a.getAttribute('href') + eval(a.getAttribute('data-with')))};

  <td><%= store.title %></td>
  <td><%= store.location %></td>
  <td><%= store.street %></td>
  <td><%= store.houseNumber %></td>
  <td><%= store.zipCode %></td>
  <td><%= %></td>
  <td><%= store.handelsRegisterNummer %></td>
  <td><%= store.taxIdentificationNumber %></td>
  <td><%= link_to "PDF Template", store.pdfTemplate(:original, false)
unless store.pdfTemplate_file_name.blank? %></td>
  <td><%= link_to :edit, edit_store_path(store), :remote => true %></

    <%= link_to :deactivate, deactivate_store_path(store), {:remote =>
true, 'data-with' => "',value=>'+$('showDisabled').checked"} unless
store.deactivated? %>
    <%= link_to :activate, activate_store_path(store), :remote => true
unless store.activated? %>


So, i got a working checkbox which refreshes the page through my store
partial. What isn't working yet, are the links with included checkbox
state. I'm not sure if my checkbox is the best way to do this, so I'm
open for suggestions :slight_smile: