【问题标题】:<p:calendar> button is hidden when disabled="true", how to make it appear anyway?<p:calendar> 按钮在 disabled="true" 时隐藏,如何让它出现?
【发布时间】:2016-10-22 15:34:48
【问题描述】:
<p:calendar ... disabled="#{bean.disabled}" />

启用后,您可以看到打开弹出窗口的按钮:

禁用时,此按钮消失:

我也想在禁用模式下显示按钮。我怎样才能做到这一点?

【问题讨论】:

  • 为什么这个按钮在禁用模式下消失,应该显示

标签: jsf button primefaces calendar disabled-input


【解决方案1】:
// this function make the button in disabled mode
function disableCalendar(){
    $(".ui-datepicker-trigger ").prev().attr("disabled","disabled");
    $(":button").filter(".ui-datepicker-trigger ").attr("disabled","disabled");

}
// this function remove the disabled mode
function abilitaCalendar(){
    $(":button").filter(".ui-datepicker-trigger ").removeAttr("disabled");
    $(".ui-datepicker-trigger ").prev().removeAttr("disabled");
}

【讨论】:

  • 虽然此代码可能会回答问题,但提供有关此代码为何和/或如何回答问题的额外上下文可提高其长期价值。
【解决方案2】:

从'p:'标签前缀来看,我想你使用的是primefaces。

按钮被禁用,因为弹出窗口的出现没有意义,用户将无法修改组件中的日期。

你想达到什么目的?

如果您想禁用输入文本框并强制用户使用日期选择器弹出窗口,您可以使用 readonlyInput=true 属性。

【讨论】:

  • 您的答案是@Alice 的更好解决方案。
  • 嗨 gybangi,抱歉我的回复晚了
  • 谢谢你的回答,但我的问题不是这样的
  • 在禁用模式下,这个按钮完全看不到。我只是想在禁用模式下看到这个按钮,但是当这个按钮点击时它不需要弹出,因为它处于禁用模式,对吧?
  • 我只想看到这个按钮不是弹出来的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多