More in this section

Forums / General Discussions / Adding embedded JS to a widget

Adding embedded JS to a widget

2 posts, 0 answered
  1. Vyacheslav
    Vyacheslav avatar
    11 posts
    Registered:
    18 Nov 2010
    19 Apr 2011
    Link to this post
    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.
  2. Vyacheslav
    Vyacheslav avatar
    11 posts
    Registered:
    18 Nov 2010
    19 Apr 2011
    Link to this post
    I've found error at my js file, all works fine now,
2 posts, 0 answered