problem after update from 3.3 to 3.4

problem after update from 3.3 to 3.4

by Przemek Gala -
Number of replies: 2

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: -
In reply to Przemek Gala

Re: problem after update from 3.3 to 3.4

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin 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.

In reply to Davo Smith

Odp: Re: problem after update from 3.3 to 3.4

by Przemek Gala -

Did not help.

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