gpt4 book ai didi

javascript - mootools 触发点击事件。如何传递自己的数据?

转载 作者:行者123 更新时间:2023-11-28 08:56:17 25 4
gpt4 key购买 nike

我有一个父元素的单击事件,并将该事件委托(delegate)给其子元素。但是,我希望能够触发此单击并将模拟单击事件的信息传递给事件监听器。

$('rt-main').addEvent('click:relay(.catClick)', function(e){
e.stop();
new Request({
method: 'get',
url: 'index.php?option=com_categories&tmpl=component&view=listing&cat=' + this.get('id'),
onComplete: function(response){
$('rt-main').set('html', response);
}
}).send();
});

// Here I want to fire the event. But how to pass in 'id' of my choosing?
// I know that this particular line fires the first anchor. How do I target a
// psuedo-anchor? Or is it better to target a class?
$('rt-main').fireEvent('click',
{target: $('rt-main').getElement('a'), stop: Function.from}
);

最佳答案

迪米塔尔是正确的。您只需在参数中传递id: "data",并在事件处理程序中添加对传入数据的检查。

这是一个 JSFiddle:http://jsfiddle.net/JT7MG/

关于javascript - mootools 触发点击事件。如何传递自己的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18439895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com