Should `.trigger()` more clearly indicate that it does not invoke event listeners created outside of jQuery?

Aperta
#1,191 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
1-3 ore
Idoneità per principianti
48/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
jquery
Ambito
documentation

Direzione di ricerca

Inizia dalla documentazione di .trigger() all’indirizzo https://api.jquery.com/trigger/ e rivedi la spiegazione esistente degli handler associati con .on() e i metodi abbreviati. Aggiorna la pagina per distinguere esplicitamente questi handler dai listener aggiunti con EventTarget.addEventListener(), quindi verifica che la formulazione spieghi chiaramente la differenza rispetto a dispatchEvent().

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I have been using jQuery for about 9 years, and only just today did I realize that $('#element').trigger('change'); is not equivalent to $('#element')[0].dispatchEvent(new Event('change'));.

On a careful reading of https://api.jquery.com/trigger/, it does indicate:

Any event handlers attached with .on() or one of its shortcut methods are triggered...

However, I wonder if there should be a more explicit callout that listeners for event types added via EventTarget.addEventListener() are not invoked.

I believe I had my incorrect expectation because I did not realized there was a semantic difference between a DOM EventListener and a jQuery event handler, and because I was already used to using jQuery as a sort of friendly, cross-browser interface for other Web APIs (Noting that new Event() never received support in IE, for example).

Lingua principale
HTML
Stelle
324
Fork
259
Merge medio
1g 30m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di jquery/api.jquery.com

Tutte le issue di jquery/api.jquery.com

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.