I am in the process of updating datatables to AJAX. There are Action buttons, some redirect to other pages and the one I am stuck with opens a modal. I am working in a Decorator file.
Here is the code that works with without modal buttons:
def dt_actions
links = []
links << h.link_to(h.content_tag(:i, "", class: "fa fa-search") " View", h.training_provider_client_path(context[:current_provider], object), class: "btn btn-primary btn-xs m-r-5px")
links << h.link_to(h.content_tag(:i, "", class: "fa fa-pencil") " Edit", h.edit_training_provider_client_path(context[:current_provider], object), class: "btn btn-default btn-xs m-l-5px")
This is the line of code that is pre-AJAX that I can't seem to format as above:
a.btn.btn-success.btn-xs.m-l-5px.clients-issue-certs-modal-link> href="#" data-toggle="modal" data-target="#choose-course-modal0" data-client-id="#{client.id}"
=> fa_icon 'graduation-cap', text: 'Issue Certificates'
= fa_icon 'chevron-right'
Also for reference, here are the two top links pre-AJAX, that I was able to convert:
= link_to training_provider_client_path(client.owner, client), class: '' do
= fa_icon 'search', text: 'View'
- if policy(client).edit?
= link_to edit_training_provider_client_path(client.owner, client), class: 'btn btn-default btn-xs' do
= fa_icon 'pencil', text: 'Edit'
Any help will be much appreciated!
CodePudding user response:
I think this should work
h.link_to(h.content_tag(:i, "", class: "graduation-cap") " Issue Certificates" h.content_tag(:i, "", class: "chevron-right"), "#", class: "btn btn-success btn-xs m-l-5px clients-issue-certs-modal-link", data: {toggle: "modal", target: "#choose-course-modal0", "client-id" => client.id})