Table: RailsNotes
User: dreamable
Created at: 2021-02-12 23:43:49 UTC
Updated at: 2021-02-13 00:11:40 UTC
Reference:(Table ID 3, Record ID 23)

标题 :
Bootstrap Tooltips
笔记 :
  • Tooltips vs popover
    • Popovers require Tooltips to be included.
    • popovers have an option to display both a title and content, while tooltips only have an option to display a title.
    • Tooltips are typically only visible on hover, Popovers are typically dismissable, whether by click on other parts of the page or second clicking the popover target (depending on implementation)
    • Although it should be noted due to accessibility problems, potential SEO issues, and lack of discovery of the tooltip/popover, neither are recommended unless you absolutely need them.
  • Install
    • check package.json, make sure 'bootstrap' and 'popper' are installed
  • Usages

    • Add to js
    // Tooltips
    $(document).on("turbolinks:load", function() {
      $('[data-toggle="tooltip"]').tooltip();
    });
    
    • In the views, add
      data-toggle="tooltip" data-placement="left" title="Tooltip on left"
      // Or define a helper 
      def fmt_tooltip(title,position="top")
         {'data-toggle': 'tooltip', 'data-placement': position, title: title}
      end
    
Tag: