I'm having issues getting external JS files into my widget. I created the widget with Sitefinity Thunder, and it registered everything fine on the server, and I'm able to pull in my widget from the toolbox. I've tried multiple ways, including random embedding and path changes, on this Sitefinity 5.3 instance with no luck, so hopefully someone can tell me the correct way to add it.
Currently, I have the build action set on all these files to NOT embed, but rather stay the default of "Content". Here's my resource links definition at the top of my user control:
<sf:ResourceLinks ID="resourceLinks" runat="server">
<sf:ResourceFile Name="~/Custom/User Controls/Event Calendar/eventCalendar_v402/css/eventCalendar.css" Static="true" />
<sf:ResourceFile Name="~/Custom/User Controls/Event Calendar/eventCalendar_v402/css/eventCalendar_theme_responsive.css" Static="true" />
<sf:ResourceFile Name="~/Custom/User Controls/Event Calendar/eventCalendar_v402/css/paragridma.css" Static="true" />
<sf:ResourceFile Name="~/Custom/Widgets/EventCalendar/eventCalendar_v402/js/jquery.eventCalendar.js" />
<sf:ResourceFile Name="~/Custom/Widgets/EventCalendar/eventCalendar_v402/js/jquery.timeago.js" />
They are not loading at all. What do I need to do to get these added in my user control (and note that the plugins need to be loaded AFTER JQuery).
PS. I tried adding a rad script manager to my user control, but it always says I can't have more than one instance on a page, even though I did not choose to add the manager when creating my test page.
Can anyone from Telerik please assist?
You have correctly referenced the .js files, however please note that you need the following:
1. Register the script inside AssemblyInfo.cs class of the class library
2. The script file build action should be "EmbeddedResource".
There are also several articles which can help you with the registration of custom JS files:
the Telerik team
Thanks for the info. I have things working (my ending problem was actually that I forgot to put UseEmbeddedThemes="false" in the definition of my ResourceLinks tag, and I didn't need to register the files in the assembly).
However, I still have another issue. The JS files I'm attempting to load are a JQuery plugin. The problem I'm seeing is that I can't get my files to load after JQuery does, so the scripts always fail because they don't have access to $ from JQuery. How can I make my scripts load after JQuery when defining my custom JS files in my user control/widget?
Can you check the following article which contains a discussion on the proper loading of JQuery:
the Telerik team