-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Including additional js libraries #150
Comments
I would also very much like to know how to do this. I am able to define data and methods in the script tag of the vuetify template; I started by implementing the datatable example and then added a script tag above the template to modify the filtering behaviour, like so:.
However, I can't get imports to work, it seems that any lines of javascript above |
You could import libraries with requirejs: export default {
methods: {
updatePlot() {
requirejs(['https://cdn.plot.ly/plotly-1.58.4.min.js'], (Plotly) => {
Plotly.react(...)
})
}
}
} But you can't add any javascript outside |
thanks for the answer, that is very useful. Many thanks |
I couldn't get this to work, it says "requirejs not defined". When I try to follow the instructions from requirejs it says to include a script tag which loads the require.js module, and to put the source code in a separate javascript file (for example, <script data-main="js/app.js" src="js/require.js"></script> but then that doesn't work either. |
Ah, yes, in Jupyter Lab requirejs is not available (in the classic notebook and in Voila it is), you could load it yourself: ...
methods: {
async updatePlot() {
await this.loadRequire()
requirejs(['https://cdn.plot.ly/plotly-1.58.4.min.js'], (Plotly) => {
console.log('Plotly loaded', Plotly)
// Plotly.react(...)
})
},
loadRequire() {
if (window.requirejs) {
return Promise.resolve()
}
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js';
script.onload = resolve;
script.onerror = reject;
document.head.appendChild(script);
});
}
} |
Thanks, trying out your example in classic jupyter notebook or voila works. However, I'd like to download the javascript module and import it locally. When I attempt to do that with the plotly example, I get a 403 (forbidden error). I put the Can requirejs work with local files? |
requirejs can, but jupyter-server doesn't serve files from your working directory. I don't know how to get it to serve static files. |
I see for example lodash is included |
Is there a way to include additional javascript libraries or custom js modules?
The text was updated successfully, but these errors were encountered: