Hello,
i'm developping a plugin that uses filepickers.
As i understood from the Moodle js doc the good practice of js coding in Moodle is loading my js files through AMD module.
So i simply want to load my filepicker, with my options.
I tried in my php file :
$PAGE->requires->js_call_amd('local_indexation/filepicker', 'init', [$myoptions]);
define(['jquery', 'core_filepicker'],
function ($, filepicker) {
function initManage(myoptions) {
var options = {
crexternallink: true,
return_types: 14
};
$.extend(options, myoptions);
$("#id_choose_thumbnail").on("click", function () {
options.accepted_types = [".thumbnail"];
options.formcallback = function (data) {
$("input[name=\'thumbnailid\']").val(data.url);
};
filepicker.show(Y, options);
});
}
return {
init: function (myoptions) {
initManage(myoptions);
}
};
});
I've obviously set $CFG->cachejs = false;
But i always have the error :
No define call for core_filepicker
(or No define call for core/filepicker if i change the require to core/filepicker)
So, what is the right way to load this code using AMD ?
Thank you