我有一个父元素的click事件,并将事件委托给它的子元素。但是,我希望能够触发此点击并将模拟的点击事件的信息传递给事件监听器。
$('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}
);
答案 0 :(得分:0)
Dimitar是正确的。您只需在参数中传递id: "data"
,并在传入数据的事件处理程序中添加一个检查。
这是一个JSFiddle:http://jsfiddle.net/JT7MG/