Adding embedded JS to a widget

Posted by Community Admin on 03-Aug-2018 10:28

Adding embedded JS to a widget

All Replies

Posted by Community Admin on 19-Apr-2011 00:00
Hi.

What is the recommended way to add js script to a widgets, that are placed in the separate assembly? I've tried to use the Telerik.Sitefinity.Web.UI.ResourceLinks control like this (at the widget's layout):
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
<%@ Register TagPrefix="sitefinity" Namespace="Telerik.Sitefinity.Web.UI.PublicControls" %>
<sitefinity:ResourceLinks ID="resourcesLinks" runat="server" UseEmbeddedThemes="True">
    <sitefinity:ResourceFile AssemblyInfo="MyAssembly.WebSite.EP.Controls.SlideShow, MyAssembly.WebSite.EP.Controls" Name="MyAssembly.WebSite.EP.Controls.Resources.Scripts.jquery.slideShow.js" Static="true"/>
</sitefinity:ResourceLinks>

All worked fine, but when I've added to the same page another widget with javascript embedded something strange was happen. The second widget layout embed js script like this  (at the widget's layout):
<%@ Register TagPrefix="sitefinity" Namespace="Telerik.Sitefinity.Web.UI" %>
<sitefinity:ResourceLinks ID="RequestFormResource" runat="server"  >
    <sitefinity:ResourceFile AssemblyInfo="MyAssembly.WebSite.EP.Controls.RequestInfoForm, MyAssembly.WebSite.EP.Controls" Name="MyAssembly.WebSite.EP.Controls.Resources.Scripts.dialogs.js" Static="true" />
</sitefinity:ResourceLinks>

It seems to me, that both javascripts weren't added to the page. When I removed the javascript embedding from the first widget, the second starts working and vise verca.

All my widgets are inherited from a SimpleView class and placed in the separate assembly. I've tried to use JavaScriptEmbedControl control like this:

<sitefinity:JavaScriptEmbedControl ResourcesAssemblyInfo="MyAssembly.WebSite.EP.Controls" runat="server" ID="slideShow" Url="MyAssembly.WebSite.EP.Controls.Resources.Scripts.jquery.slideShow.js" ScriptEmbedPosition="Head" />
but this way isn't working.
Posted by Community Admin on 19-Apr-2011 00:00
I've found error at my js file, all works fine now,
This thread is closed