1

親要素へのクリック イベントがあり、そのイベントをその子要素に委任しました。ただし、このクリックを発生させ、シミュレートされたクリック イベントの情報をイベント リスナーに渡したいと考えています。

$('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}
);
4

1 に答える 1

0

ディミターは正しい。id: "data"引数を渡し、渡されたデータのイベント ハンドラーにチェックを追加するだけです。

ここに JSFiddle があります: http://jsfiddle.net/JT7MG/

于 2013-08-26T09:16:35.447 に答える