【发布时间】:2020-01-31 15:00:52
【问题描述】:
我是该领域的新手。我遇到了一个解决方案,例如我在表头中有复选框,通过该复选框,我必须选中取消选中所有子复选框。 我向父复选框添加了一个 onclick 事件,如下所示
%th End Date
%th= check_box_tag id: "select_all_checkboxes", label: "B2B Check", onclick:"Tickets.select_all_checks();"
%th SLA
这是表格数据中子复选框的位置。
- products.each_with_index do |p, index|
- content_for :products_brief, flush: true do
%tr
%td{ "type"=> "button", "class"=> "btn btn-link has-popover", "data-toggle"=> "popover", "title"=> "#{p.serial_no}", "data-content"=> "#{yield(:products_brief)}", "data-html" => "true", "data-trigger" => "hover", "data-placement" => "right" }
- if params[:page]
= (index+1)+ 10*(params[:page].to_i-1)
- else
= (index+1)
%td=p.serial_no
- if params[:from_where] != "cus_product"
%td= text_field_tag "contract_product_additional_params[#{p.id}][amount]",0, class: "form-control cus_product_amount1", required: true
%td= text_field_tag "contract_product_additional_params[#{p.id}][discount_amount]",0, class: "form-control cus_product_disamount1", required: true
%td= text_field_tag "contract_product_additional_params[#{p.id}][contract_start_at]",Date.today, class: "datepicker form-control", required: true
%td= text_field_tag "contract_product_additional_params[#{p.id}][contract_end_at]", Date.today, class: "datepicker form-control", required: true
%td= check_box_tag "contract_product_additional_params[#{p.id}][contract_b2b]",nil, class: "form-control selectable_checkbox", required: true
%td= select_tag "contract_product_additional_params[#{p.id}][sla_id]", options_from_collection_for_select(SlaTime.where(active: 1), :id, :description ) , label_method: :description, include_blank: false, label: "SLA"
%td= label_tag "#{p.owner_customer_name}"
%td.hide= hidden_field_tag "contract_product_additional_params[#{p.id}][installed_location_id]", p.owner_customer_id
%td= label_tag "#{p.location_address.try(:full_address)}"
%td.hide= hidden_field_tag "contract_product_additional_params[#{p.id}][location_address_id]",p.location_address_id
我不知道要为这个事件编写 jquery 代码。你能帮帮我吗
select_all_checks: ->
_this =$(e)
【问题讨论】:
标签: jquery ruby ruby-on-rails-4 coffeescript