2010-09-02 119 views
0
<rich:calendar id="orderpickDate" oninputfocus="check(#{myForm.packingListId})" 

創建日曆時,您會看到一個輸入字段和彈出日曆的img。Richfaces日曆 - 如何禁用加載頁面後彈出日曆

在JS函數I可以禁用輸入字段:

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

回答

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