10 examples of 'jquery trigger custom event' in JavaScript

Every line of 'jquery trigger custom event' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
82function trigger (el, eventName) {
83 var customEvent = new CustomEvent(eventName);
84 el.dispatchEvent(customEvent);
85}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

37function triggerEvent(element, eventName) {
38 $(element).trigger(eventName);
39}
6export function trigger(element: HTMLElement, eventType: string, eventArgs: any): void {
7 let evt;
8 if (doc.createEvent) {
9 evt = doc.createEvent("HTMLEvents");
10 evt.initEvent(eventType, true, true);
11 } else {
12 evt = doc.createEventObject();
13 evt.eventType = eventType;
14 }
15
16 evt.eventName = eventType;
17 ko.utils.extend(evt, eventArgs);
18
19 if (doc.createEvent) {
20 element.dispatchEvent(evt);
21 } else {
22 element.fireEvent("on" + evt.eventType, evt);
23 }
24}
163function trigger (el, eventName) {
164 if (eventName === 'onmount' || eventName === 'onremount') {
165 el.__redom_mounted = true;
166 } else if (eventName === 'onunmount') {
167 el.__redom_mounted = false;
168 }
169
170 var hooks = el.__redom_lifecycle;
171
172 if (!hooks) {
173 return;
174 }
175
176 var view = el.__redom_view;
177 var hookCount = 0;
178
179 view && view[eventName] && view[eventName]();
180
181 for (var hook in hooks) {
182 if (hook) {
183 hookCount++;
184 }
185 }
186
187 if (hookCount) {
188 var traverse = el.firstChild;
189
190 while (traverse) {
191 var next = traverse.nextSibling;
192
193 trigger(traverse, eventName);
194
195 traverse = next;
196 }
197 }
198}
312function trigger (eventName, event) {
313 if (hasUpdateFlag) return
314 appCacheNanny.trigger(eventName, event)
315}
41trigger(eventName: string,...args) {}
4function trigger(element, eventType, eventArgs) {
5 var evt;
6 if (document.createEvent) {
7 evt = document.createEvent("HTMLEvents");
8 evt.initEvent(eventType, true, true);
9 } else {
10 evt = document.createEventObject();
11 evt.eventType = eventType;
12 }
13
14 evt.eventName = eventType;
15 ko.utils.extend(evt, eventArgs);
16
17 if (document.createEvent) {
18 element.dispatchEvent(evt);
19 } else {
20 element.fireEvent("on" + event.eventType, evt);
21 }
22}
5function trigger(element, eventType, eventArgs) {
6 var evt;
7 if (doc.createEvent) {
8 evt = doc.createEvent("HTMLEvents");
9 evt.initEvent(eventType, true, true);
10 }
11 else {
12 evt = doc.createEventObject();
13 evt.eventType = eventType;
14 }
15 evt.eventName = eventType;
16 ko.utils.extend(evt, eventArgs);
17 if (doc.createEvent) {
18 element.dispatchEvent(evt);
19 }
20 else {
21 element.fireEvent("on" + evt.eventType, evt);
22 }
23}
23function triggerEvent(type, data) {
24 var event = new Event('flo_' + type);
25 event.data = data;
26 window.dispatchEvent(event);
27 return event;
28};
12function trigger(event) {
13 if (events[event]) {
14 events[event].apply(null, [].splice.call(arguments, 1, 1));
15 }
16}

Related snippets