3

I'm analyzing a plugin as I want to modify it. I see various events firing functions like this:

    document.getElementById(this.config.form).addEventListener("submit", this._submit, false);

My question is - what does false on the end actually do? Is it the same as adding return = false on the end of a function? If so, what is the purpose of adding this?

2
  • Sometimes simply looking up the function in google will give you an answer Commented Jul 31, 2013 at 10:45
  • I actually tried but could not find what I was after. If I knew to search for useCapture it would have been easy. Commented Jul 31, 2013 at 10:49

2 Answers 2

6

It's useCapture variable.

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 for a detailed explanation. If not specified, useCapture defaults to false.

See MDN.

Sign up to request clarification or add additional context in comments.

Comments

2

Taken from : https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener

useCapture Optional 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 for a detailed explanation. If not specified, useCapture defaults to false. Note: useCapture became optional only in more recent versions of the major browsers; for example, it was not optional prior to Firefox 6. You should provide this parameter for broadest compatibility.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.