More in this section
Forums / Developing with Sitefinity / Javascrit Script Block in RadListView Layout Template?

Javascrit Script Block in RadListView Layout Template?

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. omhoge
    omhoge avatar
    5 posts
    Registered:
    12 Jan 2007
    13 Dec 2016
    Link to this post

    How so include a JavaScript block in the LayoutTemplate of a RadListView so it only appears once?

    When I save it in Sitefinity it cannot parse the template unless the script is in the itemtemplate.

    The code is below and works but I need to move the JavaScript so it is not added in every item.

     

    <%@ Control Language="C#" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Comments" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>

    <sf:SitefinityLabel id="title" runat="server" WrapperTagName="div" HideIfNoText="true" HideIfNoTextMode="Server" />
    <telerik:RadListView ID="NewsList" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
     
      <LayoutTemplate>
        <div id="card-columns-container" class="card-columns">
          <asp:PlaceHolder ID="ItemsContainer" runat="server" />
        </div>
      </LayoutTemplate>
     
      <    >
     
        <div class="card locatShadow" data-sf-provider='<%# Eval("Provider.Name")%>'  data-sf-id='<%# Eval("Id")%>' data-sf-type="Telerik.Sitefinity.News.Model.NewsItem">
          
          <asp:Repeater runat="server" DataSource='<%# Eval("FeaturedImage") %>'>
            <itemtemplate>
              <!--<a class="card-img-top img-responsive" href='<%# Eval("MediaUrl") %>'>-->
              <img style="margin: 0 auto;" class="card-img-top img-fluid"  width="100%"   src='<%# Eval("MediaUrl")%>' alt='<%# Eval("AlternativeText")%>' title='<%# Eval("Title") %>' />
              <!--</a>-->
            </itemtemplate>
          </asp:Repeater>
          
          <div class="card-block">
          
            <div class="card-subtitle ">
              <sitefinity:HierarchicalTaxonField ID="EditorialArticleColumns" DisplayMode="Read" runat="server" TaxonomyMetafieldName="EditorialArticleColumns" TaxonomyId="5130645a-942c-603c-a006-ff00004b110b" WebServiceUrl="~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc" AllowMultipleSelection="true" Expanded="false" ExpandText="ClickToAddTags" BindOnServer="true" LayoutTemplatePath="~/SFRes/Telerik.Sitefinity.Resources.Templates.Fields.HierarchicalTaxonFieldReadMode.ascx"/>
            </div>
            
            <div class="card-subtitle sfnewsMetaInfo sfmetainfo">
              <sf:FieldListView ID="PublicationDate" runat="server" Format="{PublicationDate.ToLocal():MMM dd, yyyy}" />
            </div>
            
            <h4 class="card-title sfnewsTitle sftitle">
              <sf:DetailsViewHyperLink TextDataField="Title" ToolTipDataField="Description" data-sf-field="Title" data-sf-ftype="ShortText" runat="server" />
            </h4>
            
            <sf:FieldListView ID="summaryCustom" runat="server" Text="{0}" Properties="summaryCustom" WrapperTagName="div" WrapperTagCssClass="sfnewsSummary sfsummary card-text" EditableFieldType="ShortText"/>
                    
                    <script type="text/javascript">
                        $('div.sfnewsSummary > img').removeAttr('align');                    
                        $('div.sfnewsSummary > img').removeAttr('style');
                        $('div.sfnewsSummary > img').css("margin","0 1em  2em  1em");
                    </script>
          </div>
        </div>
      </itemtemplate>
    </telerik:RadListView>
    <!--<sf:Pager id="pager" runat="server"></sf:Pager>
    <asp:PlaceHolder ID="socialOptionsContainer" runat="server" />-->

1 posts, 0 answered