• <small id='ODzTI'></small><noframes id='ODzTI'>

  • <legend id='ODzTI'><style id='ODzTI'><dir id='ODzTI'><q id='ODzTI'></q></dir></style></legend>
      <bdo id='ODzTI'></bdo><ul id='ODzTI'></ul>

      1. <i id='ODzTI'><tr id='ODzTI'><dt id='ODzTI'><q id='ODzTI'><span id='ODzTI'><b id='ODzTI'><form id='ODzTI'><ins id='ODzTI'></ins><ul id='ODzTI'></ul><sub id='ODzTI'></sub></form><legend id='ODzTI'></legend><bdo id='ODzTI'><pre id='ODzTI'><center id='ODzTI'></center></pre></bdo></b><th id='ODzTI'></th></span></q></dt></tr></i><div id='ODzTI'><tfoot id='ODzTI'></tfoot><dl id='ODzTI'><fieldset id='ODzTI'></fieldset></dl></div>

        <tfoot id='ODzTI'></tfoot>

        Rails 中的 HTML 标题属性仅显示第一个单词

        HTML title attribute in Rails displaying only first word(Rails 中的 HTML 标题属性仅显示第一个单词)

        <legend id='KPlTQ'><style id='KPlTQ'><dir id='KPlTQ'><q id='KPlTQ'></q></dir></style></legend>

            <tbody id='KPlTQ'></tbody>
              • <small id='KPlTQ'></small><noframes id='KPlTQ'>

                <i id='KPlTQ'><tr id='KPlTQ'><dt id='KPlTQ'><q id='KPlTQ'><span id='KPlTQ'><b id='KPlTQ'><form id='KPlTQ'><ins id='KPlTQ'></ins><ul id='KPlTQ'></ul><sub id='KPlTQ'></sub></form><legend id='KPlTQ'></legend><bdo id='KPlTQ'><pre id='KPlTQ'><center id='KPlTQ'></center></pre></bdo></b><th id='KPlTQ'></th></span></q></dt></tr></i><div id='KPlTQ'><tfoot id='KPlTQ'></tfoot><dl id='KPlTQ'><fieldset id='KPlTQ'></fieldset></dl></div>
                • <bdo id='KPlTQ'></bdo><ul id='KPlTQ'></ul>
                  <tfoot id='KPlTQ'></tfoot>

                • 本文介绍了Rails 中的 HTML 标题属性仅显示第一个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  遇到了一个奇怪的小问题.

                  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 basically did this in my view:

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

                  奇怪的是,虽然所有模型调用都正常工作(item.name 和 item.description 调用了正确的东西),但当我悬停时,只显示 item.description 的第一个单词.换句话说,如果 item.description 是这是一个超级酷的项目!",当我用 item.name 将鼠标悬停在该 div 上时,悬停只会显示This".

                  The weird thing is, while all the model calls are working correctly (item.name and item.description are calling up the right things), only the first word of item.description is showing up when I hover. In other words, if item.description is "This is a super cool item!", when I hover over that div with item.name, the hover just says "This".

                  这可能与 :description 属性有关,该属性目前是文本类型(我认为这是用于长字符串,就像我的描述一样).但也许不是.

                  This may have something to do with the :description attribute, which is currently of type text, (which I thought was for long strings, like my descriptions). But maybe not.

                  知道为什么会发生这种情况,以及如何解决吗?

                  Any idea why this might be happening, and how to fix it?

                  推荐答案

                  我认为您需要在视图中的 HTML 中添加引用.如果您在生成的 HTML 上查看源代码,我敢打赌它看起来像这样:

                  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! >
                  

                  浏览器会将其解释为具有 title 且值为 Thisdiv,然后是名为 is 的属性code>、asupercoolitem!.

                  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!.

                  如果您将视图更改为:

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

                  那么你生成的 HTML 应该是这样的:

                  Then your generated HTML should look like this:

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

                  这篇关于Rails 中的 HTML 标题属性仅显示第一个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Why doesn#39;t CSS hover work on table rows when the cells inside the rows have class names?(当行内的单元格具有类名时,为什么 CSS 悬停在表格行上不起作用?)
                  How to apply a CSS class on hover to dynamically generated submit buttons?(如何在悬停时将 CSS 类应用于动态生成的提交按钮?)
                  div hover background-color change?(div 悬停背景颜色变化?)
                  How to change background color and text of hover options in select?(如何更改选择中悬停选项的背景颜色和文本?)
                  Gradient Button to background-color blinks on hover(悬停时背景颜色的渐变按钮闪烁)
                  How to make hovering over active button not use hover effect?(如何使悬停在活动按钮上不使用悬停效果?)
                    <tbody id='xpWPZ'></tbody>
                • <tfoot id='xpWPZ'></tfoot>
                      <bdo id='xpWPZ'></bdo><ul id='xpWPZ'></ul>
                        <legend id='xpWPZ'><style id='xpWPZ'><dir id='xpWPZ'><q id='xpWPZ'></q></dir></style></legend>

                            <small id='xpWPZ'></small><noframes id='xpWPZ'>

                          1. <i id='xpWPZ'><tr id='xpWPZ'><dt id='xpWPZ'><q id='xpWPZ'><span id='xpWPZ'><b id='xpWPZ'><form id='xpWPZ'><ins id='xpWPZ'></ins><ul id='xpWPZ'></ul><sub id='xpWPZ'></sub></form><legend id='xpWPZ'></legend><bdo id='xpWPZ'><pre id='xpWPZ'><center id='xpWPZ'></center></pre></bdo></b><th id='xpWPZ'></th></span></q></dt></tr></i><div id='xpWPZ'><tfoot id='xpWPZ'></tfoot><dl id='xpWPZ'><fieldset id='xpWPZ'></fieldset></dl></div>