How to add/compile/link an external CSS in AppDesigner, same with JQuery

We have this project, created category/by folder (css folder, views folder (html), js folder). I use AppDesigner and embed my index.html and run but it doesn't load all the styles and jquery. How can I link/compile it?

Answers (1)

Hello John,
I understand you're facing an issue where external CSS and JS scripts linked in your HTML file aren't loading in MATLAB App Designer's HTML component. Let's address this step-by-step:
Root directory
|- views
|- index.html
|- CSS
|- style.css
|- JS
|- script.js
Here are some steps to resolve this issue:
1. According to the MATLAB documentation for the ‘uihtml component, referenced files like CSS and JS scripts should be in the same folder or a subfolder of your ‘index.html’ file. Therefore, consider moving your index.html file out of the views folder and into the root directory, where the CSS and JS folders are located.
2. Ensure that the paths to your CSS and JS files in ‘index.html’ are relative to the file's location or use full paths. For example:
<script src="./JS/script.js"></script>
3. The ‘uihtmlcomponent in MATLAB cannot access third-party JavaScript libraries such as ‘jquery.min.js’ via a Content Delivery Network (CDN). Therefore, you need to download libraries like jquery.min.js and place them in your project directory.
Example: root >> JS folder >> jquery.min.js
Hope this helps.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products

Release

R2020a

Asked:

on 8 Dec 2021

Answered:

on 11 Oct 2024

Community Treasure Hunt

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

Start Hunting!