Can I use html tags in twitter-bootstrap popover data-content? Can I use html tags in twitter-bootstrap popover data-content? ruby-on-rails ruby-on-rails

Can I use html tags in twitter-bootstrap popover data-content?


You need to create a popover instance that has the html option enabled (place this in your javascript file after the popover JS code):

$('.popover-with-html').popover({ html : true });

Then the link syntax would be:

<%= link_to('Q', '#', :class => "popover-with-html", :title => "Quality", "data-content" => "#{some_content_object.html_safe}") %>

If you're dynamically generating the content, then you need to use html_safe like David suggested so Rails doesn't escape the HTML code. Otherwise, you can just place HTML directly within that content attribute.


Yes, you can do that, but you need to call html_safe on your string (if the string is generated by Rails)

link_to 'Q', '#', :title => "Quality", :rel => 'popover', "data-content" => "Did they do a good job? <ol><li> for Really Nice </li><li>...</li></ol>".html_safe }