0

I went through many solutions on stackoverflow regarding the same but still my concept is not clear.
What I understood is it should be kept false when there is no activity to be called from device ready's linked function. i.e

 document.addEventListener("deviceready", onDeviceReady, false);

Here in onDeviceReady function if there is no activity to be called then only it should be kept as false. Tell me whether i am correct or not ?.
If not then please correct me in simple words.
I came to know that the third parameter is called as

useCapture

Dawson Loudon
  • 6,029
  • 2
  • 27
  • 31
himmatwala
  • 19
  • 1
  • 8
  • 1
    See this http://stackoverflow.com/questions/7398290/unable-to-understand-usecapture-attribute-in-addeventlistener – Griffith Nov 03 '15 at 15:05

2 Answers2

1

The document.addEventListener function is actually part of JavaScript, not Phonegap.

You can find documentation on Mozilla Developer Network here: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener

The third parameter is indeed called useCapture

From the MDN page linked above:

If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree. Events which are bubbling upward through the tree will not trigger a listener designated to use capture. See DOM Level 3 Events and JavaScript Event order for a detailed explanation. If not specified, useCapture defaults to false.

It seems to toggle JavaScript event capturing: http://www.quirksmode.org/js/events_order.html#link2 This means the container's handler will fire before it's children's.

Joseph Reeve
  • 460
  • 3
  • 13
0

What I understood is if there are two device ready's statements .
For eg:

 document.addEventListener("deviceready", onDeviceReady, false);
 document.addEventListener("deviceready", onDeviceReady, true);  

The one which is true will be executed first and then the false one.
I think I am correct this time

himmatwala
  • 19
  • 1
  • 8