?
Solved

jquery - Real beginner stuff.

Posted on 2011-09-02
2
Medium Priority
?
201 Views
Last Modified: 2012-08-13
I know these questions probably seem dumb, but after reading a lot of examples, I can't find something that will simply explain/show the setup of js file.
First, in asp.net 2008 I have a choice of adding an Ajax Client Library and a jScript file.  Does it matter which one I select?
Second, In a custom js file, can I add multiple functions or do you create a new js file for each function.
Third, does every js file start with jQuery(document).ready(function() when you have referenced the jquery-1.6.2.min.js in a masterpage?

Thanks
0
Comment
Question by:Sheritlw
2 Comments
 
LVL 5

Accepted Solution

by:
-null- earned 2000 total points
ID: 36474250
Hi there,

First of all, I would go with just a jscript file. jQuery has ajax routines built into, and I would imagine you'll just be using them over the microsoft version.  Choosing jscript file will create a new blank file.

Secondly,

Sure! put as many functions as you like in a custom file.  Normal practice would be to group your functions into logical groups in the same file.  That of course doesn't stop you from putting just one function in a file, you can do as you please. (Although in terms of performance, putting multiple functions in the same file improves load time, as the browser does not have to make a roundtrip several times to the server for each file.

Lastly,

You can reference $(document).ready in every file you include, if there is something in each you want to initialise. It however is not a requirement, a js file can simply be full of jquery functions that you call as and when.

hth

-null-

0
 

Author Closing Comment

by:Sheritlw
ID: 36475260
Thank you.  Your explanation helped a lot.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question