Local javascript in uihtml

13 Ansichten (letzte 30 Tage)
Christoph Zuidema
Christoph Zuidema am 24 Mär. 2020
Beantwortet: Christoph Zuidema am 26 Mär. 2020
How can I use locally installed javascript libraries in an App Designer uihtml component?
I managed to successfully run the code below with the MATLAB web browser.
But it's not possible to get the same result in a uihtml figure. No warning or error.
I hoped that the javascript interpreter is the same...
Examples like the Code MATLAB Response to Data Change in JavaScript from https://www.mathworks.com/help/matlab/ref/uihtml.html are working.
jquery_example.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Document Ready Demo</title>
<script type="text/javascript" src="{LOCAL PATH TO INSTALLATION FOLDER}\jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").text("Hello World!");
});
</script>
</head>
<body>
<p>Not loaded yet.</p>
</body>
</html>
uihtml mockup code:
fig = uifigure('Position',[561 497 333 239]);
h = uihtml(fig);
h.HTMLSource = 'jquery_example.html'

Akzeptierte Antwort

Christoph Zuidema
Christoph Zuidema am 26 Mär. 2020
Just in case someone is wondering, I managed to get a solution:
I put the js library in the same folder as the .mlapp file. Then it worked perfectly. The reason is actually that I wanted to get LaTeX text into the App Designer.
Now, using MathJax.js (mathjax.org) one is able to get LaTeX style equations in App Designer. I used the npm package manager to get the MathJax JS library on my computer and copied the es5 folder into my folder mentioned above. Then the MathJax has access to all its references and it works. Probably there exists a nicer solution but for a workaround to get nice LaTeX equations it works!

Weitere Antworten (0)

Produkte


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by