Help - Need process to use custom javascript libraries (work

Posted by Community Admin on 04-Aug-2018 01:49

Help - Need process to use custom javascript libraries (work with jquery)

All Replies

Posted by Community Admin on 25-Nov-2013 00:00

Hi, 
First sorry for my bad english.
After many hours to try use a js plugin (it work with our jquery version) and navigation on forum threads, i dont understand the way to use it.
I probably missed something to do.

Should somebody explain me how to use a custom js lib (work with j query, so it need be loaded) IN A USER CONTROL (not master page).
I probably dont understand how resourcelinks works.

on each threads i have read, never all the process is describe.
please say me this steps:

-which folder may i use to js files (app_themes ... global?)

-how do i resolve path on a custom user control (or template from basics ones)
                         should i use resourcelinks, or something else?

I m using sitefinity 6, and i m now testing it for my company to buy it, but i have a lot of trouble with that, so i really need help.

Thanks a lot

Posted by Community Admin on 25-Nov-2013 00:00

This is the best article i have found for use <sf:ResourceLinks>.

www.sitefinity.com/.../how_to_use_jquery_and_other_javascript_libraries_in_sitefinity

  I typically have my jQuery loaded on a master page and then in my controls use a standard <script src="/path/to/js"></scirpt> to put other libraries.  In regards to where to store the JavaScript I typically place it in ~/App_DataSitefinity/WebsiteTemplates/NameOfTheme/App_Themes/NameOfTheme/JS
Make sure in your .ascx when you try and use your library that you use $(window).load();

Posted by Community Admin on 28-Nov-2013 00:00

Thanks for your fast answer, 
i tried tu use resource link, but i ll try this way.

Posted by Community Admin on 28-Nov-2013 00:00

You SHOULD load jquery though resourcelinks

Like this

<sitefinity:ResourceLinks runat="server" UseEmbeddedThemes="false">
    <sitefinity:ResourceFile JavaScriptLibrary="JQuery" />
    <sitefinity:ResourceFile JavaScriptLibrary="KendoWeb" />
</sitefinity:ResourceLinks>

I have this right above </head> and never have an issue...just make sure the jsembed control loads at the bottom, OR you include your scripts in resourcelinks...never had an issue.

The reason you need jQuery loading in resourcelinks is every telerik widget that uses jquery has it defined, so if you have it in your header as <script src='...'/> then resource links has no idea it's already loaded and in the page, so you'll get 2 jquery instances loading.

The resourcelinks controls main function is to make sure a script loads ONLY once.  So if you have 42 widgets on the page all needing jquery, then it doesn't load the thing 42 times, only once.

Posted by Community Admin on 28-Nov-2013 00:00

The problem for me is not to load  jquery, it works fine. i use this code (resourcelinks and resourceFiles) in user controls.
its the way to use my own scripts. i tried to load it with resource links, but if i understand, i should use resourcefile for embeded libraries (like jquery, kendo or jquery ui) in master pages, and use a <script> tag for my own script.

but, if i use script tag in user controls, if i use 2 same widgets, i ll have 2 times same script right?

Posted by Community Admin on 28-Nov-2013 00:00

Yeah if you (in your widgets) just use script tags or the javascript widget itself...2 widgets = 2 same scripts.

ResourceLinks was designed to solve that for you

Posted by Community Admin on 02-Dec-2013 00:00

Hello,

Thank you Steve for your help. Damien you could also take a look at Gabe Sumners blogs post on the matter:

http://www.sitefinity.com/blogs/gabesumner/posts/gabe-sumners-blog/2011/09/01/how_to_use_jquery_and_other_javascript_libraries_in_sitefinity

Example:

<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
<sf:ResourceLinks ID="resourcesLinks" runat="server">
 <sf:ResourceFile JavaScriptLibrary="JQuery"/>
</sf:ResourceLinks>

Where the javascript library property accepts the following values:

public enum JavaScriptLibrary
   
       /// <summary>
       /// No library
       /// </summary>
       None,
       /// <summary>
       /// jQuery JavaScript library
       /// </summary>
       JQuery,
       /// <summary>
       /// Mootools JavaScript library
       /// </summary>
       Mootools,
       /// <summary>
       /// prototype JavaScript library
       /// </summary>
       Prototype,
       /// <summary>
       /// JQuery FancyBox
       /// </summary>
       JQueryFancyBox,
       /// <summary>
       /// Kendo.all scripts
       /// </summary>
       KendoAll,
       /// <summary>
       /// Kendo.web scripts. These scripts are included in Kendo.all.
       /// </summary>
       KendoWeb,
       /// <summary>
       /// jQuery Cookie library
       /// </summary>
       JQueryCookie,
       /// <summary>
       /// jQuery Validate library
       /// </summary>
       JQueryValidate,
       /// <summary>
       /// jQuery UI library
       /// </summary>
       JQueryUI
   

Regards,
Stefani Tacheva
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed