[英]Richfaces calendar - how to disable popup of calendar after page is loaded
<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彈出窗口?
找到了一個簡單的解決方案。
輸入字段ID = shippingForm:orderpickDateInputDate
img ID = shippingForm: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&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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.