Jquery datepicker integration in jsf

I followed the examples here and here , but I can't get it to work. could you help me?

This is where I define the script and below, where I (suppose) use it ...

<script> $(function() { $( "#createDate" ).datepicker({ showOn: "button", buttonImage: "images/calendar.gif", buttonImageOnly: true }); }); </script> <ui:define name="columnFilters"> <th> <h:inputText value="#{listModel.creationDate}" id="creationDate" valueChangeListener="#{listController.filterFieldChanged}"> <f:convertDateTime pattern="yyyy-mm-dd"/> </h:inputText> </th> <th> <h:inputText value="#{listModel.updateDate}" id="upateDate" valueChangeListener="#{listController.filterFieldChanged}"> <f:convertDateTime pattern="yyyy-mm-dd"/> </h:inputText> </th> <th> &nbsp; </th> </ui:define> 
+4
source share
1 answer

The jQuery ID selector should match the exactly generated HTML client id, which you can see when you do a rightclick and view the source in a browser.

Instead, use hook for the class name instead, it also allows you to select multiple elements. For instance.

 $(".datepicker").datepicker({ showOn: "button", buttonImage: "images/calendar.gif", buttonImageOnly: true }); 

with

 <h:inputText value="#{listModel.creationDate}" styleClass="datepicker" valueChangeListener="#{listController.filterFieldChanged}"> <f:convertDateTime pattern="yyyy-mm-dd"/> </h:inputText> <h:inputText value="#{listModel.updateDate}" styleClass="datepicker" valueChangeListener="#{listController.filterFieldChanged}"> <f:convertDateTime pattern="yyyy-mm-dd"/> </h:inputText> 
+7
source

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


All Articles