experimenter
experimenter

Reputation: 778

How can I use YUI Node with jQuery?

I'm using Portal Software that uses the YUI Library as its native JS Framework and I want to use jQuery on the various YUI Nodes.

Can someone please show me how this is done? I've tried the following with no success...

YUI().use('node', function (Y) {
    var oneElementById     = Y.one('#foo');
    $(oneElementById).css('color','red');

});

Upvotes: 0

Views: 823

Answers (2)

Evan
Evan

Reputation: 680

For what you're doing in your example, you could do something like:

var nativeDomElementById = Y.one('#foo').getDOMNode();
$(nativeDomElementById).css('color','red');

In general, for fluency between YUI and jQuery, see the http://jsrosettastone.com site that Kevin mentioned. You have to be careful when "crossing the streams" between YUI and jQuery, as they use different abstractions around nodes & events.

If you're working with jQuery and YUI together in a YUI sandbox -- say, you want to load a jQuery plugin alongside YUI, this recipe from the YUI 3 Cookbook might be helpful: https://github.com/evangoer/yui3-cookbook/blob/master/examples/loading/use_jquery.html

And if you get stuck, drop into #yui IRC channel on freenode.net. Good luck!

Upvotes: 2

Kevin
Kevin

Reputation: 632

Why would you want to do that? to do what you want you just use setStyle instead of css, the api is very similar JS Rosetta stone jquery and yui api comparison

Upvotes: 1

Related Questions