Richfaces日历 - 如何在加载页面后禁用日历弹出窗口

时间:2010-09-02 07:08:50

标签: jquery richfaces

<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弹出窗口?

1 个答案:

答案 0 :(得分:0)

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

输入字段id = shipmentForm:orderpickDateInputDate

img id = shipmentForm:orderpickDatePopupButton

我使用以下JQuery代码:

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

隐藏/显示img:

    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;
    }