Help - Need process to use custom javascript libraries (work with jquery)
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
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();
Thanks for your fast answer,
i tried tu use resource link, but i ll try this way.
You SHOULD load jquery though resourcelinks
Like this
<
sitefinity:ResourceLinks
runat
=
"server"
UseEmbeddedThemes
=
"false"
>
<
sitefinity:ResourceFile
JavaScriptLibrary
=
"JQuery"
/>
<
sitefinity:ResourceFile
JavaScriptLibrary
=
"KendoWeb"
/>
</
sitefinity:ResourceLinks
>
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?
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
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