oh yes, take a look at Delegator part of Behavior: 
https://github.com/anutron/behavior

nice!

>From the docs:

Included in the library is also a file called Delegator which is 
essentially the same thing except for events. For example, let's say you 
have a predictable UI pattern of having a link that, when clicked, it hides 
a parent element. Rather than writing that code each time:

document.body.addEvent("click:a.hideParent", function(e, link){
  e.preventDefault();
  link.getParent().hide();
});


You register this pattern with Delegator and now you just do:

<a data-trigger="hideParent" data-hideparent-options ="{'target': 
'.someSelector'}">Hide Me!</a>


sweet.

On Thursday, May 2, 2013 12:36:08 AM UTC+2, Mushr00m wrote:
>
> Hi (again) !
>
> I've a general question about events. Sometimes I have to put the multiple 
> events on a same element, like "focus" and "blur". So I have to repeat 
> twice the same code just for 2 different events like :
> $('myElement').addEvents({
>     focus: function(){
>         Do my action
>     },
>     blur: function(){
>         Do my action (the same)
>     }
> });
>
> Is there a way to simplify this to have both events doing the same code ? 
> (I search and found nothing with mootools to do this, I think JQuery does 
> and called it Binding events)
>
> Thanks
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mootools-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to