i have an iphonestyle checkbox button made with a gem (ios-checkboxes) . I want through this button to show only some table rows(the completed/not completed specifications), depending on the button state. If i press it first time, works correct, after that it stops working.
Here is the view code.
= 'Show completed specifications'
= check_box @specifications, :status_set
%br
%table(id = "specifications")
%thead
%tr
%th Title
%th Added
%th
%tbody
- @specifications.each do |spec|
- if spec.status
%tr{class: "completed"} // here i add a class on the COMPLETED specifications
%th= spec.title
%th= spec.created_at.strftime("%d-%m-%y %H:%M")
%th= link_to "View", project_specification_path(params[:project_id], spec.id)
- else
%tr{class: "not_completed"} // NOT COMPLETED specifications
%th= spec.title
%th= spec.created_at.strftime("%d-%m-%y %H:%M")
%th= link_to "View", project_specification_path(params[:project_id], spec.id)
the coffeescript code
$('.iPhoneCheckContainer').live "click", -> // the checkbox class
is_completed = @.checked
if is_completed
$('.completed').show()
$('.not_completed').hide()
else
$('.completed').hide()
$('.not_completed').show()
The problem was with
Looks like the ios-checkboxes gem doesn t work like a normal checkbox.
I resolve the problem by adding a new class on the button with a function that switches a variable between true/false on any click event. Depending on that variable I displayed the completed/not completed specifications.