At 11:48 AM -0400 4/1/08, John Campbell wrote:
> http://www.webbytedd.com/b/ajax/
Your code is fine for trivial example pages, but would be a disaster
for a production application.
1) The use of the global 'http' is sloppy and limiting.
2) You need to highlight the selected menu after the callback
completes. Your coding style will quickly become a mess of
document.getElementByIds().
3) You use browser detection... you should use object detection. A
try/catch block is a good idea in your case.
4) Your implementation breaks the back button.
5) Clicking the currently selected navigation element causes
unnecessary requests.
With a library, I can fix all of these issues and cut the amount of
code down from 50 lines to 10 lines. If you were to fix these issues
yourself, your code would grow to more than 250 lines.
-John C.
-John C.:
I didn't say I just the sharpest crayon in the box. :-)
You said:
1) The use of the global 'http' is sloppy and limiting.
Please explain.
You said:
2) You need to highlight the selected menu after the callback
completes. Your coding style will quickly become a mess of
document.getElementByIds().
That was just a simple example, here's a bit more complicated template:
http://webbytedd.com/a/ajax-site/
But, to add another page is trivial -- so, I think production for a
typical site would hold up.
You said:
3) You use browser detection... you should use object detection. A
try/catch block is a good idea in your case.
Open to be shown. :-)
You said:
4) Your implementation breaks the back button.
Only because there's no history. If you access it via here:
http://webbytedd.com/a.php (last item on the right)
You'll have back history.
You said:
5) Clicking the currently selected navigation element causes
unnecessary requests.
Yeah, that's one of my pet peeves too. I just didn't fix it. It's
easy enough via:
http://sperling.com/examples/smart-menu/
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php