我有一个用 gem (ios-checkboxes) 制作的 iphonestyle 复选框按钮。我希望通过此按钮仅显示一些表格行(已完成/未完成的规范),具体取决于按钮状态。如果我第一次按下它,工作正常,之后它停止工作。
这是查看代码。
= '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)
咖啡脚本代码
$('.iPhoneCheckContainer').live "click", -> // the checkbox class
is_completed = @.checked
if is_completed
$('.completed').show()
$('.not_completed').hide()
else
$('.completed').hide()
$('.not_completed').show()