0

I am trying to use a datepicker using native JSF( without any exotic faces) however since I discovered that it doesnt have native support, I have tried to implement it using jquery. However I have tried literally every solution for doing this on the internet, and the datepicker calendar just doesnt show up when i click on the textbox. In the console of the dev tools, it seems to be giving an error of "the method datepicker is not defined". why so? I have literally tried including&excluding every single library. Below is my most recent attempt.

 <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <script type="text/javascript" src="scripts/jquery-ui-1.8.21.custom.min.js"></script>
                          <script type="text/javascript">
    $(function(){
        $("#dateOfExpense").datepicker();
    });
        <h:inputText size="20" id="dateOfExpense"/>
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Arnold
  • 181
  • 3
  • 12
  • `` is an invalid reference !! – Pugazh Mar 22 '17 at 08:10
  • Use some CDN like `` and ``. Make sure you have a working internet connection in that machine. – Pugazh Mar 22 '17 at 08:12
  • Isn't your `id` something like `yourform:dateOfExpense`? My guess is that your selector is wrong. – Jasper de Vries Mar 22 '17 at 08:24
  • @JasperdeVries, that could be true. since jsf auto names it#s elements and form elements weirdly when not named externally, what should I do to make it work?( even though i dont have a form element right now) Shall i use class selector instead? – Arnold Mar 22 '17 at 08:41
  • @Pugazh Are those all libraries I need to include to make it work(imagine right now i have no libraries imported)? – Arnold Mar 22 '17 at 08:41
  • You need a form. Use something like `#yourform\:dateOfExpense` as your selector. – Jasper de Vries Mar 22 '17 at 08:43
  • @anant - Yes, jQuery UI library is needed to render `datetimepicker`. You need to first load *jQuery*, then *jQuery UI( – Pugazh Mar 22 '17 at 08:43
  • If i do "inspect element" this is how it is interpreted in the html: – Arnold Mar 22 '17 at 08:48
  • @Pugazh: tried loading all the libraries. didnt work. Btw do i need to give the form some explicit ID and/or Name too? – Arnold Mar 22 '17 at 09:36
  • You don't need to explicitly ID your form, but then an ID will be generated. More info on naming containers: http://stackoverflow.com/questions/8634156/how-to-find-out-client-id-of-component-for-ajax-update-render-cannot-find-compo – Jasper de Vries Mar 22 '17 at 10:09

0 Answers0