By this time, I haven't found a doc, to find out how to use it for any other .js file, as you know lots of .js files are on CDN servers, there should be a general rule for writing the code...
It is any JavaScript expression that returns true if the the library is loaded. Be sure it doesn’t throw an error if not loaded. The typical test is window.<some global from the library>
Thanks a lot for answering . I've seen the reference before but nothing about what you said :
The typical test is window.<some global from the library>
I solved my case by using asp-fallback-test="window.L" , and I saw the leaflet codes, many places used L.Somthing !! So I used L as global and it worked. but if you would mind getting more explanation about global, I searched
Leaflet.js but all the variable are inside function(t,i), I looked at
Leaflet Docs it is using L every where...
the other point, always we have 404 error on not loading first resource... I hope you meant "not throwing error" is any error except 404
Member
3 Points
15 Posts
asp-fallback-test for loading leaflet.js
Dec 08, 2020 06:50 AM|ehsan_kabiri_33|LINK
I need to complete using leaflet.js in asp-callback tag helper:
leaflet.js
By this time, I haven't found a doc, to find out how to use it for any other .js file, as you know lots of .js files are on CDN servers, there should be a general rule for writing the code...
All-Star
57874 Points
15505 Posts
Re: asp-fallback-test for loading leaflet.js
Dec 08, 2020 03:36 PM|bruce (sqlwork.com)|LINK
It is any JavaScript expression that returns true if the the library is loaded. Be sure it doesn’t throw an error if not loaded. The typical test is window.<some global from the library>
https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/script-tag-helper?view=aspnetcore-5.0
Member
3 Points
15 Posts
Re: asp-fallback-test for loading leaflet.js
Dec 08, 2020 04:26 PM|ehsan_kabiri_33|LINK
Thanks a lot for answering . I've seen the reference before but nothing about what you said : The typical test is window.<some global from the library>
I solved my case by using asp-fallback-test="window.L" , and I saw the leaflet codes, many places used L.Somthing !! So I used L as global and it worked. but if you would mind getting more explanation about global, I searched Leaflet.js but all the variable are inside function(t,i), I looked at Leaflet Docs it is using L every where...
the other point, always we have 404 error on not loading first resource... I hope you meant "not throwing error" is any error except 404
All-Star
57874 Points
15505 Posts
Re: asp-fallback-test for loading leaflet.js
Dec 08, 2020 05:11 PM|bruce (sqlwork.com)|LINK
leaflet.js is built as a javascript module, so normally you'd supply the name when importing. but the build exports leaflet a global defined as L
https://github.com/Leaflet/Leaflet/blob/master/package.json
https://github.com/Leaflet/Leaflet/blob/master/build/rollup-config.js