I am working on a project. but I am stuck with something. I have a main index page and a second page that is accessible by a route by clicking on a button. In that page I link to a .js script. just like this:
But it does not run the script.js. When I put the script in the index page it does not work too. But when I put the css of the second page in the index then it will run the css for the second page. Please can someone help me out?!
I am still a beginner with framework7, so I donât have any idea anymore how to fix this issue.
There is a way to use the css or js . If your js file do not contain a framework7 specific syntax , then, you can refer it in your second_page.f7.html like:-
<script src="static/second.js"></script>
Put your js file is static file directory.
If your file contains something which is specific to framework7 like dom library($$) , you will need to use app.js , edit your âapp.jsâ as:-
Sorry for late reply, but it looks like you are not using webpack build . If this is the case, my solution will simply not work. A simple way for using framework7 features without webpack build is to load them every time when a new page is added or use a webpack build.
Thanks! Managed to get it working by placing the script directly inside the page:init, however now the same thing seems to be happening with the css. Any solutions?
This method is only valid for js . For css , do following:-
1)Create .css file inside static/css/ folder, for example first.css.
2)Suppose we want to use this css in second.f7.html. Open this page and write, <link rel="stylesheet" type="text/css" href="static/css/first.css">.
Iâm already using this method, it should work but i advise you to write your css in app.css already present in src/css folder. There is hardly any performance difference i noticed in both approaches while iâm testing on android(which offers worst performance for cordova app).