I recently watched DHHs presentation at RailsConf09 (http://
railsconf.blip.tv/file/2081411/). I think the "unobstrusive"
similar) is very interesting.
I'm using these HTML5 data-attributes already in some of my projects
I was curious about how this would be implemented in Rails3, but
didn't find any changes regarding this in the rails3/master-branch.
My concern with this is just about performance. So I've tried to set
up a quick performance test (using jQuery in Firefox 3).
The test may be not very representative, but I guess that the results
will not differ very much in other browsers. If you've got 5.000 HTML
elements like this
<a href="http//something.com/action/url" data-remote=true
jQuery needs about 240ms to find all links with the data-remote=true
attribute (Syntax: $('a[data-remote=true]').each(...)).
Looking for a-tags by class jQuery only needs 50ms to find all links
So... my suggestion is just to use classes (like "_rails_remote_link")
for finding remote forms, links etc. I know that it is unlikely to
have 5.000 links on a single page, but if you could use classes
instead of data-attributes with a performance gain of about 400%, it's
worth to think about that?