Reputation: 25239
this is my code, taken from YUi examples
YUI().use('anim', function(Y) {
var anim = new Y.Anim({
node: '#demo',
duration: 0.5,
easing: Y.Easing.elasticOut
});
var onClick = function(e) {
anim.set('to', { xy: [e.pageX, e.pageY] });
anim.run();
};
Y.one('#demo-stage').on('click', onClick);
});
the problem is I already have built functions in jQuery like
$("#demo-stage").bind('click',function(){
// do something...
});
so how can Imerge them together? Can I call from jquery bind the anim? how? Y.anim? I also noticed that if I use
Y.one('.multiples-demo-stage').on('click', onClick);
It applies the click method only on the first occurence of multiples-demo-stage
div
why?
Upvotes: 1
Views: 515
Reputation: 6329
Well, using both libraries leads to a lot of code transfer on the wire. You should avoid it if you can. In fact, I'm certain you can switch pretty easily from one library to the other, just look at the JS Rosetta Stone.
Regarding your specific question, to listen to the click event on multiple nodes you need to use Y.all
instead of Y.one
:
Y.all('.multiples-demo-stage').on('click', onClick);
Upvotes: 2