如何将参数传递给 YUI3 的“on”方法回调?
我有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将任何您想要的内容作为自定义参数传递。对象、字符串、函数引用……发疯吧!
You can pass whatever you want in as those custom arguments. Objects, strings, function references... go nuts!