如何禁用字段的灰显? [英] how can I greyout a disabled field?

查看:109
本文介绍了如何禁用字段的灰显?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能不是JSF的问题,但JSF专家可能会知道更多
我在表单上有一些字段根据某些ajax请求被禁用了.我想让他们在禁用时显示为灰色.

Might not be a JSF issue but JSF experts would know this possibly more
I have some fields on the form that are getting enabled disabled based on some ajax requests . I want to show them greyed out when disabled.

让我知道您需要查看代码,但只需使用简单的

Let me know you need to see code but just using simple

<f:ajax event="keydown" execute="@this" render="field1 field2" />

字段1具有

disabled="#{not empty someBean.someProperty}"

CSS是

#content input .disabled {color: #DCDAD1; padding: 2px; margin: 0 0 0 0;background-image=""}

禁用自身可以正常工作,但不会变灰

Disabling itself is working fine but not getting greyed out

感谢和感谢JSF标签不正确

Thanks and applogies if JSF tag is not correct tag

推荐答案

JSF输入组件的disabled属性不会发出像class="disabled"这样的样式类,也不像您的CSS声明所期望的那样.它只是在生成的HTML元素上设置HTML标准的disabled属性.要亲眼看到它,请在您喜欢的浏览器中打开JSF页面,右键单击并查看源代码.看起来像

The JSF input component's disabled attribute doesn't emit a style class like class="disabled" or something like as your CSS declaration seems to expect. It just sets the HTML-standard disabled attribute on the generated HTML element. To see it with your own eyes, open the JSF page in your favourite browser, rightclick and View Source. It'll look something like

<input type="text" disabled="disabled" />

您需要使用CSS属性选择器element[attrname].如果element上存在带有attrname的属性,则将应用样式.

You need to use the CSS attribute selector element[attrname]. If the attribute with attrname is present on the element, then the style will be applied.

#content input[disabled] {
    color: #DCDAD1;
    padding: 2px;
    margin: 0 0 0 0;
    background-image: none;
}

(请注意,我修复了background-image声明,并且该声明无效)

(please note that I fixed the background-image declaration as well as it was invalid)

这篇关于如何禁用字段的灰显?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆