如何将参数传递给 YUI3 的“on”方法回调?

发布于 2024-08-24 04:55:30 字数 778 浏览 3 评论 0原文

我有 2 个事件处理程序:

Y.all(".ptl").on("mouseover", handleOverlay); 
Y.all(".ptl").on("mouseout", handleOverlay);

我想在鼠标移出时向 handleOverlay 传递一个参数,以便该函数知道用户已退出该节点并退出 handleOverlay 函数。

我尝试遵循 API http://developer.yahoo.com /yui/3/api/YUI.html#method_on 对我来说,它应该是:

Y.all(".ptl").on("mouseout", handleOverlay, null, null, null, {arg: "myarg});

但是在 handleOverlay 中,假设第一个参数是节点,第二个参数未定义,在 on 方法之前,然后在之后为 null,而不是包含传递给它的对象。

function handleOverlay(node, te) {}

node = 有问题的节点对象(如预期)

te = 在鼠标悬停之前未定义,在鼠标移开之后为 null。

我确信我错过了一些简单的事情,谢谢。

I have 2 event handlers:

Y.all(".ptl").on("mouseover", handleOverlay); 
Y.all(".ptl").on("mouseout", handleOverlay);

And I would like to pass an arugment to handleOverlay on mouseout so that the function knows that the user has exited the node and to exit the handleOverlay function.

I have attemped to follow the API http://developer.yahoo.com/yui/3/api/YUI.html#method_on which to me indicates that it should be:

Y.all(".ptl").on("mouseout", handleOverlay, null, null, null, {arg: "myarg});

however in handleOverlay, assuming that the first argument is the node, the second argument is undefined, prior to the on method, and then null after instead of containing the object passed to it.

function handleOverlay(node, te) {}

node = node object in question (as expected)

te = undefined prior to the mouseover, and null after the mouseout.

I'm sure I'm missing something simple, Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长梦不多时 2024-08-31 04:55:30
function mousedOver(e, arg1, arg2, arg3) {
    //blah blah blah arg1 arg2 arg3
}   

Y.all("#target").on("mouseover", mousedOver, null, "foo", "bar", "baz");

您可以将任何您想要的内容作为自定义参数传递。对象、字符串、函数引用……发疯吧!

function mousedOver(e, arg1, arg2, arg3) {
    //blah blah blah arg1 arg2 arg3
}   

Y.all("#target").on("mouseover", mousedOver, null, "foo", "bar", "baz");

You can pass whatever you want in as those custom arguments. Objects, strings, function references... go nuts!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文