Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a good yui replacement for jquery.live

jQuery.live

Added in jQuery 1.3: Binds a handler to an event (like click) for all current - and future - matched element. Can also bind custom events.

http://docs.jquery.com/Events/live

Is there a good YUI replacement which can do this?

like image 779
agiliq Avatar asked Nov 17 '25 19:11

agiliq


1 Answers

In YUI3, delegates perform this function. The following snippet will fire a method called "clickHandler" on any 'p' tag in the body.

YUI().use('event', function(Y) {
  Y.delegate("click", clickHandler, "body", "p");
});

YUI 2.8.0 has delegate functionality as well, but the syntax is slightly different.

like image 138
foxxtrot Avatar answered Nov 20 '25 09:11

foxxtrot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!