I have a click event to a parent element and delegated the event to its children. 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. You simply pass id: "data"
in the arguments, and add a check in the event handler for the passed in data.
Here's a JSFiddle: http://jsfiddle.net/JT7MG/