datePicker not working when not logged as an admin

Permalink
I have been building a website that requires a datepicker field.
I added this to my view file
<?php echo Core::make('helper/form/date_time')->date('claimdate', $date_field); ?>

Tested it and all worked well,

Logged out and back in as a non-admin user only to find that the datepicker has stopped working. After some digging and dropping the one line of code into a test site running
elemental I came across this error in firebug

TypeError: $(...).datepicker is not a function
$("#claimdate_pub").datepicker({

By making the user am administrator the datepicker worked again and when a user again it stopped.
I have checked that JQuery is loading, that it is declared in registerAssets.
I can see jquery is loaded in firebug.
So now I am at a loss as to why this is happening, any suggesting most welcome

This is running on a ubuntu 1404 server, using nginx and running C5.7.4.2 with no other add-ons on the page.

Thanks

FaganSystems
 
WillemAnchor replied on at Permalink Reply
WillemAnchor
Is that bit of javascript your own, or generated ?

if so, try it within a $(document).ready()
FaganSystems replied on at Permalink Reply
FaganSystems
HI I wish I could say, hey yes you are right , yes a great idea but sadily, I have only contributed the one line of php to create the datepicker, everything else is part of the core product.

I have a gut feeling its permissions somewhere but I am at a loss as to where
MrKDilkington replied on at Permalink Best Answer Reply
MrKDilkington
@FaganSystems

I think the core date picker might require jQuery UI.

If so, you can try requiring it in your page_theme.php:
- in registerAssets()
$this->requireAsset('javascript', 'jquery/ui');
FaganSystems replied on at Permalink Reply
FaganSystems
@MrKDilkington You are spot on, I added

$this->requireAsset('css', 'jquery/ui');
$this->requireAsset('javascript', 'jquery/ui');

into the page_theme.php of the elemental theme and the datepicker started working again

Thank you for your help
jgalat replied on at Permalink Reply
jgalat
I had problems with this using 5.8

$this->requireAsset('javascript', 'jquery/ui');

It seems if you just use

$this->requireAsset('jquery/ui');

It loads the asset for jquery/ui which includes both the js and css. I was having trouble using DatePicker when not logged in as Admin.