Jump to content

Implementing JQuery


rick.emmet

Recommended Posts

Hi Everyone,

I'm confused; I went to the download page for JQuery and all I got was a script (1175 lines long). This doesn't even have any comments at the top of the script. What is this? It seems far too small to be a library. If it is a library, where does it go and how do I link to it? Any explanation will be most appreciated.

Cheers,

Rick

Link to comment
Share on other sites

Which did you download? The development version is 4 lines (including a comment) and minified to keep it light. The development version is about 9,400 lines long and full of comments. Want to post the first few lines? Either way though, jQuery is light-weight.

Link to comment
Share on other sites

Since the jQuery framework is so common, it is likely that the user has a copy of it from Google in their cache already.  Many recommend utilizing Google's API powers for your jQuery hosting (unless the site will be developed offline like on a laptop at an airport).

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

 

Where it goes in your source is also debated, I prefer to put it in the footer since javascript's actions are primarily against your DOM, which is best suited after the page has fully loaded.

 

Once it's loaded on a web page, you can simply create an anonymous, self-invoking function and write your scripts

(function(){
   $('#some_div_id').hide();
})();

 

I highly recommend NetTuts+'s 30 Days to learn jQuery class.

Link to comment
Share on other sites

Hi Everyone,

First, thank you for replying, the comments are very helpful! To be a little more clear about my intended use of JQuery, I wish to download the entire library and the Form Validation Plugin and place it somewhere in the htdocs folder. I want to be able to implement the form validation locally (so I don't have to be online) and test it. I do want to get opinions from all of you as to which form validation plugin (at Google?) seems to be the most trouble free.

 

I get it that in almost every instance, linking to Google or anther CDN hosting site will perform better than having it hosted on my site. When I go live I will set up my form validation this way.

 

Back to the download, I used the link ( http://code.jquery.com/jquery-1.7.2.js ) to navigate to what I thought would be a zip file and instead got this...

 

(function($) {

$.extend($.fn, {
// http://docs.jquery.com/Plugins/Validation/validate
validate: function( options ) {

	// if nothing is selected, return nothing; can't chain anyway
	if (!this.length) {
		options && options.debug && window.console && console.warn( "nothing selected, can't validate, returning nothing" );
		return;
	}

 

Etc., etc. Yesterday the site was a mess! There were a number of pages that displayed a message saying "currently in development" and as I said before, the forum was not able to process any request to join. That is still not working. Today however, I did go back to the download page and grabbed the following code...

 

 

/*!
* jQuery JavaScript Library v1.7.2
* http://jquery.com/
*
* Copyright 2011, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
* Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: Wed Mar 21 12:46:34 2012 -0700
*/
(function( window, undefined ) {

 

Etc., etc. Is this the real thing? It looks like it might be. Do I place this in the same folder as the Form Validation Plugin? Thanks again for your help!

Cheers,

Rick

 

Link to comment
Share on other sites

Hi Mahngiel,

Well, that is the correct file. I created a JS folder in htdocs and placed the 9400 line file with a ".js" extension in it. I also place just the jquery.validate.min.js file in the folder and it does all the validation on my test form. So I can do my development on the moon if I have to.

 

Can you recommend a from validation plugin on a CDN hosting site (perhaps Google)? Thanks again for your help!

Cheers,

Rick

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.