Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (37 sloc) 1.36 KB


The purpose of this library is to provide an easy way to long-poll
on a URL for events and dispatch as they come in.


Starting and Stopping the Event Loop

$.ev.loop(url, handlers)

url – the URL you want to long-poll on.

handlers – an object that maps event types to event handlers.


    $.ev.loop('/comet/channel/foo/2894293942', {

      // ev.type == "backgroundColor"
      backgroundColor: function(ev) {
        $('body').css({ backgroundColor: ev.color });

      // ev.type == "foregroundColor"
      foregroundColor: function(ev) {
        $('body').css({ color: ev.color });

      // ev.type == "debugMessage"
      debugMessage: function(ev) {



This will stop the long-polling loop.



Event Handlers

This library makes the assumption that every event from the COMET server
will be an object with a type attribute. Based on the value of the
type attribute, jQuery.ev will dispatch events to the event handlers.

Code Examples