views:

68

answers:

2

I've been working on a complex app with one main dashboard. I don't particularly like the design because it tries to do too much on one page. So the lead developer thought it would be a good idea to use ajax - because the page is so big. Refreshing part of it is far faster than loading it again.

Problem is there's several ways data can be used.

  • Adding items
  • Editing rows
  • Performing actions on selected rows (selected using a checkbox)
  • Changing single items (like location, phone)

My problem is making GENERALIZABLE ajax code that can operate on the data in a div, using class names to assemble the proper information for the ajax call. I did pretty well, but can't help but want to see if there's a better way to do it.

A: 

I have this one open on my desk all the time:

http://www.pragprog.com/titles/cppsu/prototype-and-script-aculo-us

plodder
+1  A: 

Before I dug into jQuery, I did a lot of searching for Javascript best practices and bookmarked several articles which helped me to get my head around generally good Javascript ideas (such as unobtrusive Javascript, etc). It's possible to use jQuery or another library and do it in a way that's full of code smells.

I was a big fan of:

I don't go very far on the web without JavaScript: The Definitive Guide, 5th edition for language tips and traps.

From there, rather than picking up a jQuery book I looked online for best practices specific to jQuery. James Padolsey's jQuery Code Smells was a great post. The jQuery documentation provides tons of great code samples. I did a lot of looking into jQuery plugins (great for modularizing your code) and bookmarked A Plugin Development Pattern.

If you do want a book on jQuery, the one that came up over and over again in my reading was Learning jQuery, but based on the rapid evolution of the language, I've found that the web has more recent information.

justkt
I can't vote this up (not enough reputation), but thanks. This is very helpful!
Burton Kent
You should still be able to check the little green check box (if you think it's the right answer). As a bonus, you get rep for doing that!
justkt
Got it... thanks. And yes, great list. I'd also add this tutorial from John Resig - related to his upcoming book "Secrets of the Javascript Ninja." http://ejohn.org/apps/learn/
Burton Kent