
Functionless event handlers in jQuery - johns
http://james.padolsey.com/javascript/functionless-event-handlers-in-jquery/
======
chops
Even though the author didn't like it, I quite liked the ultra-chaining
approach presented. So what if the readability relies too much on indenting,
practically every language relies on indenting for readability (or the
indenting actually has syntactical meaning like python).

Frankly, I found this example very neat and would love to see this in jquery.

    
    
      $('div') 
        .when('click') 
            .addClass('active') 
            .text('Hey') 
        .done() 
        // Also possible with on() 
        .on('mouseout') 
            .removeClass('active') 
            .text('Ho') 
        .done();
    

It relies on indenting for readability, just like everything else. I say go
for it!

------
DanHulton
Of course, if all you want to do is add hover effects to your app, it's always
worth considering doing it in straight CSS:

    
    
      .menu {
          background-color: #fff;
      }
      .menu :hover {
          background-color: #ccc;
      }

------
subbu
Though its a neat shortcut, a new member in the team who has not heard about
the extension won't understand the code straight away. That's the problem of
modifying the core behavior of a language/framework (often called monkey-
patching).

~~~
Hexstream
That's an issue with _every single_ piece of technology (operating system,
library, application, API, programming language, CPU, non-trivial function or
macro...). As such I don't think it can be a valid statement against the
adoption of any specific technology. Besides, this particular concept is
really easy to learn.

------
erlanger
If this becomes the standard way of working with jQuery in a future release,
I'll likely switch to MooTools or another library. Code like that would be
hell to maintain.

~~~
chops
It isn't being proposed as the standard way, it is merely a proposed
alternative. Nothing wrong with other ways to do the same thing. Some prefer
other forms of syntactic sugar.

