I have a link on the index.html.erb page. Its a download link. Now I want that if the cursor hovers on the link then a tooltip text will be displayed.e I have tried several combinations but did not get the solution yet.
My code is here:
<p>
Download:
<%= link_to "CSV", users_export_path(format: "csv") %> |
<%= link_to "Excel",users_export_path(format: "xls") %>
</p>
I installed bootstrap and I want to generate bootstrap tooltip for this two links. Please tell what should I do along with right syntax.
You can set the necessary data attributes in the 'link_to' helper:
<%= link_to "CSV", users_export_path(format: "csv"), title: 'Download CSV', 'data-toggle' => 'tooltip', 'data-placement' => 'right'%> |
<%= link_to "Excel", users_export_path(format: "xls"), title: 'Download Excel', 'data-toggle' => 'tooltip', 'data-placement' => 'right'%>
then add the following js
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
Try this:
<p>
Download:
<%= link_to "CSV", users_export_path(format: "csv"), "data-toggle" => "tooltip", "data-placement" => "top", "title" => "Add a title" %> |
<%= link_to "Excel",users_export_path(format: "xls"), "data-toggle" => "tooltip", "data-placement" => "top", "title" => "Add a title" %>
</p>
And add this to your JavaScript file:
$('a[data-toggle="tooltip"]').tooltip();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With