On Oct 14, 2008, at 3:07 AM, T.J. Crowder wrote:
> So in that situation, we
> don't want the HTML designers to have to do much to enable the
> JavaScript, and we don't want the JavaScript coders to know that much
> about the HTML. We want them both to have an agreed set of things
> they each provide to the other (behaviors, etc.). This is one of the
> reasons for "unobtrusiveness" (although I'd expect someone to jump in
> here with more reasons).
What a great run through of options. Of course, I *do* want to jump
in here and add another reason for unobtrusive coding -- it enforces
the practice of "progressive enhancement". This means that if for
some reason you have disabled JavaScript (or you are using a screen
reader) the site still works. And it does so without a lot of fuss.
The trick is to add *extra* goodness using JavaScript, so that when
JS is not there, the goodies aren't there, but the site still works.
F.E.:
You have a form, and it submits to a handler somewhere. If you follow
the principle above, then you would wire up the script, and make sure
it works properly without any extra script. The handler page might be
the form itself, and the result might be an error or a success
message. All good. Now, you add a classname to your form, say 'ajax',
and then add the following to your document observer:
$$('form.ajax').invoke('observe','submit',function(evt){
evt.stop();
var elm = evt.element();
new Ajax.Updater(elm,elm.request());
});
Now your form just got "wired" for Ajax, and as long as your handler
returns the content of the form when it's requested by Ajax, and an
entire page when it's not, nothing at all has to change about your
site to handle either case.
Walter
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---