Forums

Datepicker not working after J 3.4. update

pollito 03 Mar, 2015
Hi

The datepicker does not work anymore after updating to Joomla 3.4.

Compare the form on J 3.3. http://www.travelcostarica.nu/rentalcar-reservation (working) with the J 3.4.form on http://gaggi.travelcostarica.nu/rentalcar-reservation (not working)

I have not made any changes and am loading the datpicker by "Loading JavaScript" in the Setup, using the code below:
$(function() {
    $( "#from" ).datepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,
      onClose: function( selectedDate ) {
        $( "#to" ).datepicker( "option", "minDate", selectedDate );
      }
    });
    $( "#to" ).datepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,
      onClose: function( selectedDate ) {
        $( "#from" ).datepicker( "option", "maxDate", selectedDate );
      }
    });
  });


Any idea what needs to be updated here in order for the datepicker to work?

Thanks for your thoughts!
GreyHead 03 Mar, 2015
Hi pollito,

Please wrap your code in this:
jQuery(document).ready(function($){
  // your code goes here
});

Bob
pollito 03 Mar, 2015
Hi Bob
Thanks for your quick reply! Unfortunately, this didn't solve it.
The console tells me that there is an "Uncaught TypeError: undefined is not a function": http://i.imgur.com/F37t4QE.png

My JS is too weak to understand the message... but the code caused no problems on J3.3.

Any clue? Or is there a better (native) way to use datepicker in this context?

Thanks!
/Philipp
GreyHead 03 Mar, 2015
Hi pollito,

It looks as though Max may have renamed the CF datepicker to gdatetimepicker

Bob
pollito 03 Mar, 2015
Hmm, does that mean I have to change the JS like so?
jQuery(document).ready(function($){
$(function() {
    $( "#from" ).gdatetimepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,
      onClose: function( selectedDate ) {
        $( "#to" ).gdatetimepicker( "option", "minDate", selectedDate );
      }
    });
    $( "#to" ).gdatetimepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,
      onClose: function( selectedDate ) {
        $( "#from" ).gdatetimepicker( "option", "maxDate", selectedDate );
      }
    });
  });
});


It still gives me no love:-(

Or am I wrong by calling the datepicker with the JS load function?

Best,
Philipp
Max_admin 04 Mar, 2015
Hi,

I suggest that you change the code to this:


jQuery(document).ready(function($){
    $( "#from" ).gdatetimepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,
      onClose: function( selectedDate ) {
        $( "#to" ).gdatetimepicker( "option", "minDate", selectedDate );
      }
    });
    $( "#to" ).gdatetimepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,
      onClose: function( selectedDate ) {
        $( "#from" ).gdatetimepicker( "option", "maxDate", selectedDate );
      }
    });
});


And change to use "datepicker" again like in your original code, but I'm not sure which date picker is this, I think its the jQuery ui date picker, because its NOT the Chronoforms one, and in this case you must have the jQuery UI loaded on the new site.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
pollito 04 Mar, 2015
Hi Max

Thanks for your reply! I still can't get it to work: http://gaggi.travelcostarica.nu/rentalcar-reservation
The UI resource should be present in the header (taken from http://jqueryui.com/datepicker/#date-range)

Maybe it's easiest if I use the CF native datepicker. Can you point me to the relevant resource? What would I have to do in order to get your above code to work?

Thank you and best regards,
Philipp
Max_admin 04 Mar, 2015
Hi Philipp,

Please try to use "jQuery" instead of "$" in your code.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
pollito 05 Mar, 2015
Unfortunately that doesn't work:-(
Max_admin 05 Mar, 2015
Answer
How do you load the jQuery ui ? its loaded after the other scripts, you will need to load it before the code runs, you can check this in the page source.

Also it adds another version of jQuery, so you need to get rid of that and just load jQuery ui using a Chronoforms "Load JavaScript" action.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 05 Mar, 2015
Hi Philipp,

I think there's a FAQ on using the JQuery datepicker with ChronoForms v5, you may be able to adapt that. I also suggest that you use the JQuery Easy extension if you need to load a fuller version of JQueryUI than Joomla use.

Bob
pollito 06 Mar, 2015
Thank you Max, that did it!
To reiterate the solution:
Load CSS file: http://code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css
Load JS file: http://code.jquery.com/ui/1.11.3/jquery-ui.js
(only UI file needs to be loaded, as jquery is already integrated in J3)

Load JS Code:
jQuery(document).ready(function(jQuery){
    jQuery( "#from" ).datepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,
      onClose: function( selectedDate ) {
        jQuery( "#to" ).datepicker( "option", "minDate", selectedDate );
      }
    });
    jQuery( "#to" ).datepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,
      onClose: function( selectedDate ) {
        jQuery( "#from" ).datepicker( "option", "maxDate", selectedDate );
      }
    });
});
This topic is locked and no more replies can be posted.