4

initEventを使用してイベントを作成し、後でJavaScriptでdispatchEventを使用してイベントをディスパッチすることと、jqueryのtrigger('click')トリガーを使用することの違いは何ですか?

4

1 に答える 1

4

jQueryのtrigger関数はと同じではありません。bugs.jquery.com/ticket/11047dispatchの次の表を参照してください。

"The trigger function should also dispatch custom events such that code using addEventListener can catch the custom event. However, that is not happening. In fact, that is the only of the 8 combinations listed below that does not work. We should fix this to allow better interoperability between jQuery event functions and W3C DOM event functions."

PASS: If you trigger a DOM event you can catch it using the bind function
PASS: If you trigger a DOM event you can catch it using the addEventListener function
PASS: If you trigger a custom event you can catch it using the bind function
FAIL: If you trigger a custom event you can NOT catch it using the addEventListener function
PASS: If you dispatch a DOM event you can catch it using the bind function
PASS: If you dispatch a DOM event you can catch it using the addEventListener function
PASS: If you dispatch a custom event you can catch it using the bind function
PASS: If you dispatch a custom event you can catch it using the addEventListener function
于 2012-07-25T15:56:33.940 に答える