HTML title attribute in Rails displaying only first word

后端 未结 3 601
再見小時候
再見小時候 2020-12-22 01:32

Got a weird little problem.

I want to create the text hover on an item to display that item\'s \"description,\" which is an attribute of that item\'s model. So I ba

相关标签:
3条回答
  • 2020-12-22 01:43

    Insert double qutoes for title in the div tag

    <div title="<%= item.description %>" ><%= item.name %></div>
    
    0 讨论(0)
  • 2020-12-22 01:47

    Change this line:

    <div title=<%= item.description %> ><%= item.name %></div>
    

    to this:

    <div title="<%= item.description %>" ><%= item.name %></div>
    
    0 讨论(0)
  • 2020-12-22 02:02

    I think you need to add quoting to the HTML in the view. If you view source on the generated HTML, I'm willing to bet it looks like this:

    <div title=This is a super cool item! >
    

    The browser will interpret that as the div having a title with the value This, and then attributes named is, a, super, cool, and item!.

    If you change your view to this:

    <div title="<%= item.description %>" >
    

    Then your generated HTML should look like this:

    <div title="This is a super cool item!" >
    
    0 讨论(0)
提交回复
热议问题