General developer forum

problem after update from 3.3 to 3.4

 
Picture of Przemek Gala
problem after update from 3.3 to 3.4
 

Hello, after moodle upgrade from 3.3.2+ to version 3.4.1, the JS function that used the jquery plugin has stopped working. For example, the following code does not have access to the jquery plugin and shows the error:


Uncaught TypeError: $(...).datetimepicker is not a function


The code that calls the function


$(function(){


 $('body').on('click',function(){


 $('.test').html('<input type="text" id="dataww" name="sdaf"/>');


 $('#dataww').datetimepicker({


 timepicker:false,mask:true,format: 'Y-m-d',formatTime: 'H:i',formatDate: 'Y-m-d'


 }); 


 });


})


the script is linked to the page:


$PAGE->requires->js(new moodle_url($CFG->wwwroot . '/js/jquery.datetimepicker.full.min.js'),true);




I am asking for help if I can manage it somehow / fix it to work

 
Average of ratings: -
Davo
Re: problem after update from 3.3 to 3.4
Core developersParticularly helpful MoodlersPlugin developers

Not used it in a while, but you could try $PAGE->requires->jquery() first?

The proper solution is to wrap your code in an AMD module, then load it via $PAGE->requires->js_call_amd() - see https://docs.moodle.org/dev/Javascript_Modules for a starting point.

 
Average of ratings: -
Picture of Przemek Gala
Odp: Re: problem after update from 3.3 to 3.4
 

Did not help.

It is strange that if you enter the code without a click event, the plugin works

 
Average of ratings: -