【问题标题】:JQuery Date Picker with JSF带有 JSF 的 JQuery 日期选择器
【发布时间】:2011-01-21 02:46:26
【问题描述】:

我正在为我的 JSF 使用 JQuery Date Picker 插件。

它适用于只有 1 个日期字段但超过 1 个日期字段的页面,它无法将日期值填充到我的输入字段中。

就我而言,我想知道开始日期和结束日期。

下面是我的代码:

JQUERY

$(document).ready(function(){
    $(".dateto").datepicker({ showOn: 'button', buttonImageOnly: true, buttonImage: '../resources/images/calendar.gif' });
    $(".datefrom").datepicker({ showOn: 'button', buttonImageOnly: true, buttonImage: '../resources/images/calendar.gif' });
});

JSF

<h:inputText id="from" value="#{UserManagerBean.startDate}" required="false" styleClass="datefrom" />
<h:inputText id="to" value="#{UserManagerBean.endDate}" required="false" styleClass="dateto" />

为了您的信息,我尝试了 2 个 html 输入字段,它也可以正常工作。 请帮忙!!! 谢谢你

【问题讨论】:

    标签: jquery jsf datepicker


    【解决方案1】:

    自从这个被撞到了顶峰……

    这应该可以工作(可能需要稍微调整一下):

        function initDatePickers() {
            $(document).delegate("#from, #to", "focusin", function() {
                var $this = $(this);
                $this.datepicker({
                    onClose: function(dateText, inst) { 
                      $(".ui-datepicker-calendar").hide();
                    }
                });
                $this.attr( 'readOnly' , 'true' );
            }); 
    
    
            $(document).delegate("#from, #to", "focus", function() {
                $(".ui-datepicker-calendar").hide();
            });         
        }
    

    我认为您最好从输入中删除 styleClass...

    【讨论】:

      猜你喜欢
      • 2016-02-26
      • 1970-01-01
      • 1970-01-01
      • 2012-11-17
      • 2013-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-29
      相关资源
      最近更新 更多