Solved

Html/Form events vs JQuery events

Posted on 2012-03-11
3
476 Views
Last Modified: 2012-03-12
Hi Everyone,
This might have been asked before, but I can't find a good explanation anywhere.  Which technique would be better to use; attaching an event handler to an element of a html form, such as onBlur="Handler" with its own Javascript function, or applying the handler in the $(document).ready section of  the initial Javascript section?  I'd eventually like to have it interface with php on the server side, so I know I'll have to do some Ajax on it.  Both methods look like they would give pretty much the same result, but I've seen articles online and in books that use one or the other.
Thanks
0
Comment
Question by:William-B
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Hugh McCurdy earned 500 total points
ID: 37708243
One method is not clearly better than the other.  They both end up using JavaScript (as I expect you already know).

I think the main distinction then is program maintainability.  You should choose the approach that is easier to follow.

IMHO, I think that means JQuery because I can automatically tell the maintenance engineer which areas of the page use JavaScript because I would (normally) identify areas by id and a good editor could then find id='foo' or whatever.  So, I'd choose JQuery simply because it's more obvious.
0
 

Author Comment

by:William-B
ID: 37708389
Thanks for your response.  Looking at it now I can definitely see how JQuery could make things a lot more manageable and clear for anyone else working on it.  Thanks again for your input.
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 37709326
Thanks for the points.  Program maintainability is a very important issue.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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 …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now