jsf 中每个 SelectOneMenu 项的工具提示

发布于 2024-12-23 01:04:53 字数 179 浏览 4 评论 0原文

我的要求是为每个选项提供一个工具提示 SelectOneMenu 因为选项标签太大 不可能提供这么大尺寸的 SelectOneMenu 。所以 标签正在切割。这就是为什么我需要工具提示来显示 鼠标悬停在 SelectOneMenu 中的选项上时的整个值。

任何想法将不胜感激。

My requirement is to provide a tooltip for every option in the
SelectOneMenu because label of option is so large
that it's not possible to provide such a large size SelectOneMenu .So the
label is cutting. Thats why i need tooltip to show
the whole value on mouse over of the options in the SelectOneMenu .

Any ideas will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖阳 2024-12-30 01:04:53

如果您使用“javax.faces.model.SelectItem”列表,您可以传递描述属性来显示每个选项的工具提示。

If you are using a list of "javax.faces.model.SelectItem" you can pass the description attribute to show a tooltip for each and every option.

月亮是我掰弯的 2024-12-30 01:04:53

您可以使用javascript
假设您的 selectOneMenu 如下。

<h:form id="form1">
    <h:selectOneMenu id="combo1">
        <f:selectItem itemLabel="First Label"/>
        <f:selectItem itemLabel="Second Label"/>
        <f:selectItem itemLabel="Third Label"/>
    </h:selectOneMenu>
</h:form>

将此脚本添加到页面顶部。

<script>
    window.onload = function() {
         var options = document.getElementById("form1:combo1").options;
         for(var i = 0; i < options.length; i++) {
             options[i].title = options[i].innerHTML;
         }
    }
</script>

You can use javascript.
Assume your selectOneMenu as below.

<h:form id="form1">
    <h:selectOneMenu id="combo1">
        <f:selectItem itemLabel="First Label"/>
        <f:selectItem itemLabel="Second Label"/>
        <f:selectItem itemLabel="Third Label"/>
    </h:selectOneMenu>
</h:form>

Add this script at the top of your page.

<script>
    window.onload = function() {
         var options = document.getElementById("form1:combo1").options;
         for(var i = 0; i < options.length; i++) {
             options[i].title = options[i].innerHTML;
         }
    }
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文