Phonegap Jellybean Custom Event

I created an application that works great on iOS and on all Android devices, except for those that run Jellybean. I tested Nexus 7, Nexus 5 and Galaxy Note 3 (KitKat) and it works great. However, when I tried this on Galaxy Note 2, Galaxy Note 3, and Galaxy S3, all running Jellybean got the same errors:

Uncaught TypeError: Illegal constructor:82
Uncaught Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0: 71

On line 82, I have:

var a = new window.Event(trigger);

and on line 71 I have:

elem.dispatchEvent(a);  

This application is completely web based and does not have its own plugins. So when I open a webpage in a browser, everything works fine on Jellybean phones. However, as soon as the same code is wrapped in telephone entries, I begin to see errors. What is the correct way to create custom javascript events for Jellybean?

: . jellybean : https://developer.mozilla.org/en-US/docs/Web/API/document.createEvent

// Create the event.    
var event = document.createEvent('Event');

// Define that the event name is 'build'.
event.initEvent('build', true, true);

// Listen for the event.
document.addEventListener('build', function (e) {
  // e.target matches document from above
}, false);

// target can be any Element or other EventTarget.
document.dispatchEvent(event);
+4

Source: https://habr.com/ru/post/1532756/


All Articles