如何使用JQuery或javascript(客户端)禁用丰富的日历 [英] How to disable rich calendar using JQuery or javascript (client side)
问题描述
所有的问题,我想在客户端禁用和启用 rich:calendar
(例如使用javascript fonction)。
All is in the question, I want to disable and enable a rich:calendar
on the client side (using a javascript fonction for example).
xhtml元素:
<rich:calendar id="calendar" ... />
<h:selectBooleanCheckbox id="checkbox" onclick="change('checkbox', 'calendar')" ... />
JS功能:
function change(checkbox, calendar){
if(jQuery('#'+checkbox).is(':checked')){
// Enable calendar
jQuery('#'+calendar).removeAttr('disabled');
}
else{
// Disable calendar
jQuery('#'+calendar).attr('disabled',true);
}
}
+ checkbox)
返回一个输入 input#checkbox
,但 code>返回表
表#calendar.rich-calendar-exterior
,而不是要禁用的组件。
jQuery('#'+checkbox)
returns an input input#checkbox
but jQuery('#'+calendar)
returns a table table#calendar.rich-calendar-exterior
and not the components to disabled.
如何使用JQuery(或javascript)停用丰富日历的输入和图标?
How to disable the input and the icon of the rich calendar using JQuery (or javascript) ?
编辑:
< rich:calendar id =calendar/>
产生html:
<span id="calendarPopup">
<input type="text" class="rich-calendar-input" id="calendar" name="calendar"
style="vertical-align: middle; width: 130px">
<img alt="" class="rich-calendar-button" id="calendarPopupButton"
style="vertical-align: middle" src="/project/a4j/g/3_3_3.Finalorg.richfaces.renderkit.html.iconimages.CalendarIcon/DATB/eAE7fv4Kw6znAA4mA-w_.jsf">
<input type="hidden" autocomplete="off" id="calendarInputCurrentDate" name="calendarInputCurrentDate" style="display: none" value="11/2011">
</span>
推荐答案
我找不到只使用jQuery ,因此我选择将复选框值和已禁用的日历属性绑定到同一布尔值:
I can't find a solution using only jQuery implmentation, so I choose to bind the checkbox value and the disabled calendar attribute on the same boolean :
<rich:calendar id="calendar" disabled="#{!checkboxValue}" />
<h:selectBooleanCheckbox id="checkbox" value="#{checkboxValue}">
<a4j:support event="onclick" reRender="calendar"></a4j:support>
</h:selectBooleanCheckbox>
有一个ajax(我不想)没有任何人有另一个解决方案没有ajax?没有其他解决方案,我会选择这个作为接受的答案...
There is ajax (I do not want to) does anyone have another solution without ajax ? Without other solution, I'll choose this one as the accepted answer...
这篇关于如何使用JQuery或javascript(客户端)禁用丰富的日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!