Core Docs | Additional Modules Docs

sb.events


@Description: Cross browser event handling that references the proper "this" and passes the event to the handler function. Using sb.events, multiple events can be added to a single DOM node for the same event. e.g. multiple onclick handlers
@File: sb.js

sb.events.add


@Description: Add an event listener to a DOM element, re-write of surebert events based on tips from http://www.digital-web.com/articles/seven_javascript_techniques/
@File: sb.js
@Type: function
@Param: Element/String el A reference to a DOM element or a string that can be passed through sb.$ to return a dom el e.g. '#myList'
@Param: String event The event to listen for without the on e.g. 'click'
click - fires when the use mouses down and then up on an element
contextmenu - fires when the user right-clicks on a DOM element - Not in opera
mouseover - fires when the user hovers over a DOM element
mouseout - fires when the user moves the mouse out from over a DOM element
mousedown - fires when the user press the mouse button down over a DOM element
mouseup - fires when the user lets the mouse button return to the up position over a DOM element
keydown - fires when the user presses a key when in a DOM element
keyup - fires when the user lets the key return to the up position in a DOM element
keypress - fires when the key is pressed and then returns to the upstate in a DOM element
blur - fires when a DOM element loses focus
focus - fires when a DOM element gains focus
submit - fires when a form is submitted
onload - when a element such as body or img loads
onunload - when user naviagtes away from the page
@Param: Function handler The function that is run when the event occurs. The this reference of the function is the element itself and the funciton is also passed an event object which holds data about the event e.g. clientX, clientY, target, etc The funciton can be either an anonymous inline function or a function reference
@Example:
var myEvent = sb.events.add('#myList', 'click', function(e){
        alert(this.innerHTML);
    });

sb.events.remove


@Description: Removes an event listener
@File: sb.js
@Type: function
@Param: Object event An event listener reference as returned from sb.events.add
@Example:
var myEvent = sb.events.add('#myList', 'click', function(e){
        alert(this.innerHTML);
    });

    sb.events.remove(myEvent);

sb.events.removeAll


@Description: Removes all event listeners added with sb.events.add or sb.elements or $'s event method
@File: sb.js
@Type: function
@Example:
sb.events.removeAll();