[Proto-Scripty] Re: writing unintrusive javascript with prototype

2008-10-15 Thread RobG



On Oct 14, 5:07 pm, T.J. Crowder [EMAIL PROTECTED] wrote:
[...]
 One way to do this is to have the relevant fields tagged with a
 specific CSS class.

An excellent response overall, but just for the record: the HTML class
attribute is not targeted at CSS, it is for any purpose you wish to
put it to (even none at all).  The W3C HTML 4.01 spec[1] doesn't
single out any particular use.

CSS can use the class attribute, just as it can use other element
attributes such as tagname, id and name.

1. URL: http://www.w3.org/TR/html401/struct/global.html#adef-class 


--
Rob.
--~--~-~--~~~---~--~~
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 prototype-scriptaculous@googlegroups.com
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
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: writing unintrusive javascript with prototype

2008-10-15 Thread T.J. Crowder

@RobG:

 ...just for the record: the HTML class
 attribute is not targeted at CSS, it is for any purpose you wish to
 put it to (even none at all).

Good point!

@All:

I went ahead and rewrote this as a tip on the unofficial wiki, but it
could use another pair of eyes and I'm out of time this morning:
http://proto-scripty.wikidot.com/prototype:tip-using-unobtrusive-javascript

I left out the X-JSON option because it didn't quite seem to fit.
--
T.J. Crowder
tj / crowder software / com

On Oct 15, 7:15 am, RobG [EMAIL PROTECTED] wrote:
 On Oct 14, 5:07 pm, T.J. Crowder [EMAIL PROTECTED] wrote:
 [...]

  One way to do this is to have the relevant fields tagged with a
  specific CSS class.

 An excellent response overall, but just for the record: the HTML class
 attribute is not targeted at CSS, it is for any purpose you wish to
 put it to (even none at all).  The W3C HTML 4.01 spec[1] doesn't
 single out any particular use.

 CSS can use the class attribute, just as it can use other element
 attributes such as tagname, id and name.

 1. URL:http://www.w3.org/TR/html401/struct/global.html#adef-class

 --
 Rob.
--~--~-~--~~~---~--~~
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 prototype-scriptaculous@googlegroups.com
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
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: writing unintrusive javascript with prototype

2008-10-14 Thread Walter Lee Davis


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 prototype-scriptaculous@googlegroups.com
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
-~--~~~~--~~--~--~---