Access disabled attribute for PrimeFaces calendar using JavaScript

I have a form in which some fields should be disabled until the checkbox is checked. For JSF elements, everything works fine. The problem is with the elements of the element.

For a JSF element, such as a drop-down list, I do this as follows:

<h:selectOneMenu value="countryValue" disabled="true" id="countryId">
    <f:selectItems value="countries" />
</h:selectOneMenu>

And for Primefaces-elements, a calendar list:

<p:calendar disabled="true" id="datePicker" value="dateValue" 
         pattern="yyyy-MM-dd" startWeekday="1"    
            timeZone="GMT">  
</p:calendar>

The JavaScript I used to include these elements in the event is simple as:

function enableLocationUpdateFilter()
{
    document.getElementById('form:datePicker').disabled = false;
}

jQuery calling onchange-event:

 jQuery('.countryCheckBoxId').change(function()
 {
    enableCountryFilter();
 });

Primefaces firebug, , id "datePicker" "span" id, id HTML "datePicker_input". , , "datePicker" javascript, "datePicker_input". , jQuery, , .

, jquery-. jquery- , true. , , false.

+3
2

, :

- false.
- true.
- , false.

, false ( , ), javaScript . , , . .

0

, , - Ajax- . , jQuery-onchange?

, JSF 2.0, ?

UPDATE:

, p:calendar checkBox. :

<h:selectBooleanCheckbox id="countryCheckBoxId" value="#{bean.countryBoolean}">
   <f:ajax render="datePicker"/>
</h:selectBooleanCheckbox>

<p:calendar disabled="#{!bean.countryBoolean}" id="datePicker" value="dateValue" 
        pattern="yyyy-MM-dd" startWeekday="1" timeZone="GMT">     
</p:calendar>
+4

Source: https://habr.com/ru/post/1766702/


All Articles