• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/84

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

84 Cards in this Set

  • Front
  • Back
describe the DOM Level 0 Event Model
This is an informal term used to describe how the DOM behaved before W3C released the first standard (DOM Level 2)
explain the expanded syntax that occurs in the background when the following html is parsed:

<button onclick="this.value='clicked'" />
Javascript creates a function similar to this:

button.onclick = function(event) {
this.value = 'clicked';
}
explain the purpose of this:

if( !event ) { event = window.event; }
IE doesn't pass the event appropriately, instead it stores it on the window object. This is a common method for cross-browser compatibility.
what is the equivalent of the W3C standard event.target in IE?
window.event.srcElement
explain the basic concept of event bubbling
events happen on the element activated, then "bubble up" to the parent element and so on all the way up to the document, unless something stops propagation
explain how to cancel event propagation (bubbling) in standards compliant browsers
stopPropagation()
explain how to cancel event propagation (bubbling) in IE
set window.event.cancelBubble to true
explain why the addEventListener(eventType, listener, capture) method was added in DOM Lev. 2
Because only one method could be assigned as a listener at a time; this allows multiple functions to be assigned to each event
explain the primary difference in event propagation (bubbling) between DOM 0 and DOM level 2
Events bubble up from the document to the element, and then back down again instead of just down from the element (if useCapture is false)
explain the "capture phase" in DOM level 2
this is the root to target phase, where event bubbles up from document root to the target element
explain the "bubble phase" in DOM level 2
this is the target to root phase; event propagates from the target element back up to document root
explain IE's support for DOM Level 2
It doesn't support it; it supports a proprietary bubble phase, but does not support the DOM's standards for bubble or capture phases
explain the IE equivalent for addEventListener
it uses attachEvent(eventName, handler)

note that there is no useCapture!
explain the purpose of bind()
Establishes a function as a listener to handle events of the type provided when triggered by any element in the wrapped set
explain eventType in bind(eventType, data, handler)
(String) event that is to be monitored (click, load, etc), multiple events can be a space separated list
explain data in bind(eventType, data, handler)
Object passed here is attached to the Event instance and passed to handler whenever it is invoked
explain handler in bind(eventType, data, handler)
Function that will be called when eventType occurs. The Event instance is passed to this handler and 'this' context is set to the current element in the bubble phase
explain eventMap in bind(eventMap)
A JS Object that allows multiple handlers to be assigned in a single call. Each element of the Object is a key naming the event type and a value containing the handler (same as calling bind(eventType, handler) on each element of the object)
name all the keyboard related event types for bind()
keydown
keypress
keyup
name all the focus and form related event types for bind()
focusin
focusout
focus
blur
submit
select
change
name all the mouse related event types for bind()
mousedown
mouseup
mouseenter
mouseleave
mousemove
mouseout
mouseover
scroll
name all the page related event types for bind()
load
unload
ready
resize
error
which two event types do not bubble up the DOM tree?
focus and blur - use focusin and focusout for bubbling
explain the purpose of focusin and focusout
focus and blur do not bubble up the dom tree - focusin/out provide alternatives that do bubble
define one()
establishes a callback as the event handler for a method and automatically remove it after called (use it only once)
define unbind(eventType, listener)
removes listener from the wrapped set's event listeners for eventType
define unbind(event)
removes the listener that triggered the Event passed as a parameter

this can also be a selector to be matched, such as $('*').unbind('.myListeners');
which method allows an event listener to be canceled (removed) from the list of callbacks?
unbind()
explain jQuery.Event.altKey
true if the alt key was pressed when event triggered, this in the option key on Mac
explain jQuery.Event.ctrlKey
true if control key was pressed when event triggered
explain jQuery.Event.currentTarget
current element during bubble phase. This is the same object set as the function context 'this'
explain jQuery.Event.data
a value, if any, that was passed to the bind() method when the listener was established
explain jQuery.Event.metaKey
true if the command key on mac or the control key on windows was pressed when the event triggered
explain jQuery.Event.pageX
the horizontal coordinate of the mouse event relative to page origin
explain jQuery.Event.pageY
the vertical coordinate of the mouse event relative to page origin
explain jQuery.Event.relatedTarget
for mouse events, identifies the element the cursor left or entered when the event was triggered
explain jQuery.Event.screenX
for mouse events, the horizontal coordinate of the event relative to screen origin
explain jQuery.Event.screenY
for mouse events, the vertical coordinate of the event relative to screen origin
explain jQuery.Event.shiftKey
true if shift key was pressed when event triggered
explain jQuery.Event.result
the prior result returned from an event handler that was not undefined
explain jQuery.Event.target
the element for which the event triggered
explain jQuery.Event.timestamp
time in milliseconds when event triggered
explain jQuery.Event.type
specifies the type of event triggered (i.e. 'click') - useful when using an event handler for multiple types
explain jQuery.Event.which
For keyboard events, specifies the numeric code of the key that caused the event

For mouse events, specifies the button pressed (1=left, 2=middle, 3=right)
explain the difference between jQuery.Event.which and Event.button
The .button property doesn't function reliably across browsers; jQuery's which resolves this
explain jQuery.Event.preventDefault()
Prevents any default action from occuring (form submit, radio button selection, link click, etc)
explain jQuery.Event.stopPropagation()
Prevents bubbling--the event is not passed up to any parent elements in DOM to see if they have event handlers
explain jQuery.Event.stopImmediatePropagation()
stop all event propagation, including additional events on the current target
explain jQuery.Event.isDefaultPrevented()
true if preventDefault() method has been called on 'this'
explain jQuery.Event.isPropagationStopped()
true if stopPropagation() has been called
explain jQuery.Event.isImmediatePropagationStopped()
true if stopImmediatePropagation() has been called
what happens if a callback listener attached using bind() returns false when it is invoked?
stops propagation of the event and cancels the default behavior--does not cancel _immediate_ propagation
explain the differences of Event.keycode and jQuery.Event.which
keycode does not return reliably across browsers
explain the basic purpose of live()
attaches event listeners (handlers) to a css selector; any time an element matching the selector fires the specific event, the handler is triggered

this occurs even if the element didn't exist when the handler was set

Useful for AJAX calls
explain eventType in live(eventType, data, listener)

how is it different from bind()?
the type of event the handler is invoked for

unlike bind(), this can't be a space separated list
what method can be used to attach event listeners (handlers) to a css selector?
use live()
how can events be triggered on elements that are added to the page after the event listener is established?
use live() and a css selector
explain data in live(eventType, data, listener)
Object passed to handler by attaching it to the Event whenever the handler is called

If missing, the handler can be passed as the second param
explain listener in live(eventType, data, listener)
Function that should be invoked when eventType occurs, it is passed the Event object and 'this' context is the element that triggered the event
explain any important considerations while mixing listeners bound by live() with ones bound using bind()
live() events are fired after bind()
live() events do not propagate
is the following legal? why or why not?

$('div').closest('p').live(...)
No, live() only works on css selectors and not derived sets
how are event handlers bound with live() removed?
using die()
explain eventType in die(eventType, listener)
the DOM event to stop listening for (e.g. 'click', 'load', etc)

if not provided, listener is removed for all event types
explain listener in die(eventType, listener)
Function, specifies the specific listener to be removed. If not provided, all listeners are removed.
Explain how to trigger an event handler on a specific element
use trigger(eventType, data)
explain eventType in trigger(eventType, data)
the event type to listen for (e.g. 'click', 'load', etc)
explain what happens if an ! is appended to eventType in trigger(eventType, data)
namespaced events are not triggered
explain how to define a namespace on event listeners
for bind(eventType, data, handler), simply append the eventType with a .name

for example: bind('click.myNamespace', ... )
explain how to only remove event listeners that belong to a specific namespace
for unbind(eventType, listener), add .namespace to the eventType

examples:
$('*').unbind('click.myNamespace', ...); // only clicks
$('*').unbind('.myNamespace'); // all event types in myNamespace
how can multiple event types be specified for eventType in bind(eventType, listener)
separate the event types with a space

example: bind('click focus keypress', ...)
true or false: calling jQuery's trigger() method invokes event propagation
true
when using trigger() how can namespaced events be avoided?
add an ! to the eventType, such as "click!"
true or false: calling trigger() can fire semantic actions (e.g. form submit)
true
true or false; calling triggerHandler() can fire semantic actions (e.g. form submit) and causes event propagation
false, use trigger() to fire actions and cause propagation
true or false: events bound by live() are triggered when trigger() method is invoked
true
true or false: events bound by live() are triggered when triggerHandler() is invoked
false - use trigger() to invoke them
define triggerHandler(eventType, data)
triggers event of type given for the matched set and passes data as part of the event.

unlike trigger() this does not cause event propagation or semantic actions to fire and does not fire events bound by live()
explain the basic purpose of the toggle() method
for toggle(listener1, listener2, ... )

establishes the passed functions as listeners in a circular list

so the first time the event fires, listener1 is called, the second time, listener 2 is called, and so on
true or false: only two handlers can be passed to toggle()
false, the name is for backwards compatibility, but it accepts any number of handlers
explain the difficulty with using mouseover and mouseout, when an element has chidren
the mouse over/out events are fired both when the parent element is entered and exited and when the child element is entered (as if the parent has been left)
what method can be used as an alternative to mouseenter() and mouseleave()?
the hover() method
explain hover()
for hover(enter, leave), calls the enter event onmouseenter and the leave event onmouseleave
Explain how to create a custom event handler
Use the bind() or live() methods and use a custom name in place of the normal event type:

$('...').bind('customEventName',handler);
Explain how to trigger a custom event handler
Once the handler is defined with live() or bind(), it may be triggered like any other event handler:

$('...').trigger('customEventName')