【问题标题】:Richfaces calendar - how to disable popup of calendar after page is loadedRichfaces 日历 - 如何在页面加载后禁用日历弹出
【发布时间】:2010-09-02 07:08:49
【问题描述】:
<rich:calendar id="orderpickDate" oninputfocus="check(#{myForm.packingListId})"

创建日历时,您会获得一个输入字段和一个弹出日历的 img。

在js函数中我可以禁用输入框:

function check(packId) {
  var canEditThisDate = true;

  // canEditThisDate = true/false <--  checked using jQuery.ajax() if date can still be
  // updated by the user


  if (! canEditThisDate) {
    jQuery("input[id='shipmentForm:orderpickDateInputDate']").attr("disabled", true);
  }
}

然后无法手动更改输入字段。 但是您仍然可以单击 img 并选择一个日期,然后输入字段将更新为所选日期。

如何在js函数中禁用richfaces弹窗?

【问题讨论】:

    标签: jquery richfaces


    【解决方案1】:

    找到了一个简单的解决方案。

    输入字段id = shippingForm:orderpickDateInputDate

    img id = shippingForm:orderpickDatePopupButton

    我使用以下 JQuery 代码:

            jQuery("[id*='shipmentForm:orderpickDate']").hover(function() {
                checkIfOrderPickDateCanBeUpdated(#{shipmentForm.currentPackingList.id});
            });
    

    并隐藏/显示图像:

        function checkIfOrderPickDateCanBeUpdated(packId) {
            var ret = false;
    
            jQuery.ajax({
                  url: '/wms/seam/resource/dbutil?cmd=getFreightDocIdByPackId&amp;packId=' + packId,
                  async: false,
                  success: function(data) {
                      if (data == "0") {
                          ret = true;
                      } else {
                          ret = false;
                      }
                 }
            });
    
            if (ret) {
                // enable order pick date field
                jQuery("input[id='shipmentForm:orderpickDateInputDate']").removeAttr("readonly");
                jQuery("img[id='shipmentForm:orderpickDatePopupButton']").show();
            } else {
                jQuery("input[id='shipmentForm:orderpickDateInputDate']").attr("readonly", true);
    
                jQuery("img[id='shipmentForm:orderpickDatePopupButton']").hide();
            }
    
            return ret;
        }
    

    【讨论】:

      猜你喜欢
      • 2013-06-11
      • 2014-09-27
      • 1970-01-01
      • 2013-04-25
      • 1970-01-01
      • 2014-02-08
      • 2013-02-25
      • 2017-04-07
      • 1970-01-01
      相关资源
      最近更新 更多