2

I would like to display tool tip with rich text as like below

<%= link_to 'test', '#', :title => "<b>sample</b>".html_safe %>

its not working and displaying with html tags.

Want to display html formatted text without html tags in anchor title property.

Please share your ideas.

Raju akula
  • 1,255
  • 1
  • 13
  • 18
  • How are you displaying the title? – Rajdeep Singh Mar 10 '15 at 10:11
  • @RSB, what do you mean? i want to display html formated text without html tags as it is html_safe will give us the html formatted text without tags but its not working in title -> tool tip – Raju akula Mar 10 '15 at 10:13
  • 1
    You can't put html (such as a `` tag) inside an attribute, including the title attribute. If you want "rich" popups with nice formatting instead of the standard titles then you will need to use javascript to mimic the effects of the title attribute. If you're using a "web library" like Bootstrap then it comes with this functionality already, which are called "popovers". – Max Williams Mar 10 '15 at 10:13
  • @MaxWilliams, title -> text is from db like `:title => (@project.description).html_safe` but not static format. As description field will have the text mixed with html tags for format. Yes, as you said we need to go with javascript libraries as standard titles will not work out. – Raju akula Mar 10 '15 at 10:17
  • Your code is **exact**. If you look at your query response, you should see an `test`. It's your browser it replace the html special chars in the dom attributes. – pierallard Mar 10 '15 at 11:17
  • @ForgetTheNorm yes i could see that. What is your solution? – Raju akula Mar 10 '15 at 11:25

1 Answers1

0

Finally achieved as below, by using the Jquery-ui tooltip

`

<%= link_to 'test', '#', :title => "<b>sample</b>", :id => "demo_box" %>`

    $(function(){
      $('#demo_box').tooltip({
        content: function(){
          var element = $( this );
          return element.attr('title')
        }
      });
    });

`

Raju akula
  • 1,255
  • 1
  • 13
  • 18