[英]mootools fire click event. How to pass own data?
I have a click event to a parent element and delegated the event to its children. 我将click事件分配给父元素,并将事件委托给其子元素。 However, I want to be able to fire this click and pass in the simulated click event's information to the event listener.
但是,我希望能够触发此单击并将模拟的单击事件的信息传递给事件侦听器。
$('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}
);
Dimitar is correct. Dimitar是正确的。 You simply pass
id: "data"
in the arguments, and add a check in the event handler for the passed in data. 您只需在参数中传递
id: "data"
,然后在事件处理程序中添加对传入数据的检查。
Here's a JSFiddle: http://jsfiddle.net/JT7MG/ 这是一个JSFiddle: http : //jsfiddle.net/JT7MG/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.