简体   繁体   English

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

[英]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.

相关问题 在jQuery中,如何触发在mootools中添加的elements事件? - In jQuery how to fire an elements event added in mootools? 如何在click事件上将函数值传递到文本框中。 函数值也是数组的输出 - How to pass a function value into a text box on click event. Function value is also an output of an array 单击事件未在dojox.data.Datagrid中显示数据。 - Data is not getting displayed in dojox.data.Datagrid on click event. 如何解决点击事件。 即使调试没有指向它,它也不起作用 - how to fix on click event. it is not working even the debug is not pointing toward it 如何在IE中使用mootools在click事件中捕获currentTarget? - How to catch currentTarget on click event with mootools in IE? 如何在点击事件中刷新标签内容。 WordPress和Javascript - How to refresh tab content on click event. Wordpress and Javascript 使用Dart时,我会在click事件上创建一个DOM类。 它仅拾取第一个元素,如何在所有元素上触发它? - When using Dart I am creating a DOM class on click event. It only picks up the first element, how do I have it fire on all elements? Mootools Click事件问题 - Mootools Click Event Problem Firebase发生变更事件。 如何知道谁更改了数据? - Firebase on change event. How to know who changed data? 有时需要两次轻击才能触发事件。 我该如何解决? - Sometimes it takes two taps to fire an event. How do I get around this?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM