Accessing boost AMD package from other theme

Accessing boost AMD package from other theme

by Nicolas Dalpe -
Number of replies: 1

Hi Everyone,
I am trying to use an AMD package from boost theme (/theme/boost/amd/build/collapse.min.js) in my own theme. My questions are: What is the proper way to load an AMD module inside another AMD module? And, once it is loaded, how can I use it?


What I did so far:

define(['jquery', 'theme_boost/collapse'], function($, collapse) {
return {
init: function() {
$("#element").collapse('show');
}
};
});

This gives me the error: error  'collapse' is defined but never used  no-unused-vars 


require.config({
paths: {
"collapse": "theme_boost/collapse"
}
});

define(['jquery'], function($) {

return {
init: function() {
$("#element").collapse('show');
}
};
});

This gives me the error: TypeError: a(...).collapse is not a function

I am using Moodle 3.7.1 on LAMP

Thank you in advance for your help

Average of ratings: -
In reply to Nicolas Dalpe

Re: Accessing boost AMD package from other theme

by Bas Brands -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers
Hi Nicolas,

If you change the first bit of JS to this it should compile

define(['jquery', 'theme_boost/collapse'], function($) {
return {
init: function() {
$("#element").collapse('show');
}
};
});
Average of ratings: Useful (1)