This is a migrated thread and some comments may be shown as answers.

How to use jQuery in HTML page?

11 Answers 169 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ildar
Top achievements
Rank 1
Ildar asked on 04 Nov 2011, 04:20 PM
I have a ASPX web site with Telerik controls and jQuery but there is a HTML page without any aspx or Telerik controls (*.html).
How to include jQuery in this HTML page?

11 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 04 Nov 2011, 04:58 PM
Hello Ildar,

You could use JQuery in pure HTML page the same way you would in ASPX page. Check this link for more information.

The first result is quire useful.

All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Ildar
Top achievements
Rank 1
answered on 04 Nov 2011, 08:54 PM
Hi Andrey,

I am already using this approach:
<script src="jquery.js"></script>
Is it that what you suggesting me?
What I am trying to ask is how to get rid of second copy of jQuery?
If I am using jQuery in aspx pages via Telerik, can I include it to html page without making additional copy of it?
I think a some instance of jQuery exist on the server side.
If I would known the address, I could link to that instance from html page.

Thank you,
Ildar
0
Jayesh Goyani
Top achievements
Rank 2
answered on 05 Nov 2011, 05:01 PM
0
Ildar
Top achievements
Rank 1
answered on 07 Nov 2011, 09:46 PM
Hi Jayesh,

What do you mean?
If you mean how to use jQuery then I know how to use.
If you mean how to include jQuery then I am already using this way.
Can you be a little bit more specific?

Thank you,
Ildar
0
Andrey
Telerik team
answered on 08 Nov 2011, 04:53 PM
Hello Ildar,

Please refer to this help article for additional information on how to use JQuery with RadControls.

Greetings,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Ildar
Top achievements
Rank 1
answered on 08 Nov 2011, 05:08 PM
Hi Andrey,

Thanks. This article explains how to include jQuery to aspx pages.
I am asking how to include jQuery to HTML pages without additional copy of jQuery.
I am currently using in HTML page: /<script src="myfolder/jquery.js"></script>.
But I have aspx pages too with jQuery included like:
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
Therefore I have two version of jQuery.
Can I have one?
Is it possible?

Thank you,
Ildar
0
Andrey
Telerik team
answered on 09 Nov 2011, 05:01 PM
Hello Ildar,

As described in the article I have sent you in my last reply, you have several choices to use one and the same version of JQuery.

1. Using a global variable

<script type="text/javascript">
window.$ = $telerik.$;
</script>

2. Using a self-calling anonymous function:
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
alert("Hooray! The document is ready!");
} ); })($telerik.$);
</script>
3. Using the $telerik.$ alias:
<script type="text/javascript">
$telerik.$(document).ready(function () {
alert("Document is ready");
});
</script>
4. Include a script reference to the Telerik.Web.UI.Common.jQueryInclude.js:

<telerik:RadScriptManager ID="RadScriptManager1" runat="server"
<Scripts>
 ......
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
</Scripts>
</telerik:RadScriptManager>

Which one of these you choose, it will work the same. Pick the one that is most convenient to you.

I also attach a sample project which illustrates some of the aforementioned approaches.

Kind regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Ildar
Top achievements
Rank 1
answered on 09 Nov 2011, 05:18 PM
Hi Andrey,

Where is HTML page in your sample project?
As I outlined in all my posts I am asking about HTML page: file with html extension.
For example manual.html.

Thank you,
Ildar
0
Accepted
Andrey
Telerik team
answered on 11 Nov 2011, 04:06 PM
Hi Ildar,

There is no way to include an assembly reference in pure HTML page. The HTML pages are parsed from different ISAPI filters than the ASP.NET. So the HTML ISAPI filter could not parse ASP.NET assemblies in order to use the code logic in HTML page.

However, you could check which version is used by RadScriptManager by executing the following command in your ASPX page:
$().jquery;

After this line of code has been executed, you will know what is the exact version of JQuery that the script manager uses and you will have the opportunity to include this version in your HTML page. Thus you will eliminate the multiple-versions problem across your project.

Regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Ildar
Top achievements
Rank 1
answered on 11 Nov 2011, 05:10 PM
Hi Andrey,

Thank you. This is the exactly answer what I need.
Can you give me a tip how should I formulate a question next time to prevent long time discussion (1 week)?

Thank you,
Ildar
0
Accepted
Andrey
Telerik team
answered on 15 Nov 2011, 04:47 AM
Hello Ildar,

A general rule when describing problem for which you are seeking answer from other person is to be as specific as you could when giving infromation. If you are sensing that something is unclear to the other person, it's best to try peraphrasing and to clear it out in order to prevent confusion.

For example if you had started your ticket with something like the following:

"Is there a way to include JQuery from RadControls assembly in a file with HTML extension? How to get the version of currently running instance of JQuery in RadControls?"

would be a lot better. The last reply from you, when you mentioned the HTML file extension helped me to understand what you were talking about.

However, you become good with technical communication after you get some experience on it. So, try following the aforementioned suggestions and with every next question you will get more familiar with it and it won't be a problem.


Regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
General Discussions
Asked by
Ildar
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Ildar
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or