Search code examples
c#jqueryasp.netdotnetnukedotnetnuke-module

How to set relative path to script from ascx


I have created custom DNN module.
And I want to use masonry plugin in it.
So in the module project in VS I have created Scripts folder and put JS files in there.
On the view of ascx file I have added:

<script src="Scripts/jquery.infinitescroll.min.js"></script>
<script src="Scripts/masonry.pkgd.js"></script>
<script src="Scripts/imagesloaded.js"></script>

But when I load the page eith module in console I get:

GET http://dnn7site/resources/shared/scripts/jquery/jquery.min.map 404 (Not Found) Masonry:457
GET http://dnn7site/jquery.min.map 404 (Not Found) Masonry:464
GET http://dnn7site/Demos/Scripts/masonry.pkgd.js 404 (Not Found) Masonry:751
GET http://dnn7site/Demos/Scripts/imagesloaded.js 404 (Not Found) Masonry:752
GET http://dnn7site/Demos/Scripts/jquery.infinitescroll.min.js 404 (Not Found) 

What is the way to add and set a relative path to the scripts in DNN?


Solution

  • Try including the full path to the resource files, as per the instructions on the Masonry getting started documentation:

    Include the Masonry script in your site.

    <script src="/path/to/masonry.pkgd.min.js"></script>
    

    For example:

    <script src="/desktopmodules/com.demo.masonry/Scripts/jquery.infinitescroll.min.js"></script>
    <script src="/desktopmodules/com.demo.masonry/Scripts/masonry.pkgd.js"></script>
    <script src="/desktopmodules/com.demo.masonry/Scripts/imagesloaded.js"></script>