lib/client/myelements.jquery.js
function($el) {
    // Reaction to socket.io messages
    $myelements.socket.on("message", function onMessage(message) {
      if ($el.data().templateScope === message.event) {
        // Update element scope (maybe re-render)
        var scope = {};
        scope[message.event] = message.data;
        $myelements.updateElementScope($el.get(0), scope);
      }

      // we forward socket.io's message as a jQuery event on the $el.
      $myelements.debug("forwarding backend message '%s' as jQuery event '%s' to element %s with data: %j", message.event, message.event, $el.get(0), message.data);
      // Kludge: If jQuery's trigger received an array as second parameters
      // it assumes you're trying to send multiple parameters to the event handlers,
      // so we enclose message.data in another array if message.data is an array
      // sent from the backend 
      if ($.isArray(message.data)) {
        $el.trigger(message.event, [message.data]);
      } else {
        $el.trigger(message.event, message.data);
      }
    });
    // Reaction on local events triggered on the element by jQuery
    $el.on("message", function onElementMessageEvent(jQueryEvent, message) {
      if (message.event === undefined || message.data === undefined) {
        $myelements.debug("event key or data not present in second argument to trigger()", message.event, message.data);
        console.error("myelements.jquery: $.fn.trigger('message') must be called with an object having the keys 'event' and 'data' as second argument.  ");
        return;
      }
      $myelements.debug("Sending message '%s' to backend with data: %j", message.event, message.data);
      $myelements.socket.send(message);
    });
  }
function($el) {
    // Reaction to socket.io messages
    $myelements.socket.on("message", function onMessage(message) {
      if ($el.data().templateScope === message.event) {
        // Update element scope (maybe re-render)
        var scope = {};
        scope[message.event] = message.data;
        $myelements.updateElementScope($el.get(0), scope);
      }

      // we forward socket.io's message as a jQuery event on the $el.
      $myelements.debug("forwarding backend message '%s' as jQuery event '%s' to element %s with data: %j", message.event, message.event, $el.get(0), message.data);
      // Kludge: If jQuery's trigger received an array as second parameters
      // it assumes you're trying to send multiple parameters to the event handlers,
      // so we enclose message.data in another array if message.data is an array
      // sent from the backend 
      if ($.isArray(message.data)) {
        $el.trigger(message.event, [message.data]);
      } else {
        $el.trigger(message.event, message.data);
      }
    });
    // Reaction on local events triggered on the element by jQuery
    $el.on("message", function onElementMessageEvent(jQueryEvent, message) {
      if (message.event === undefined || message.data === undefined) {
        $myelements.debug("event key or data not present in second argument to trigger()", message.event, message.data);
        console.error("myelements.jquery: $.fn.trigger('message') must be called with an object having the keys 'event' and 'data' as second argument.  ");
        return;
      }
      $myelements.debug("Sending message '%s' to backend with data: %j", message.event, message.data);
      $myelements.socket.send(message);
    });
  }
function ( $el ) { // Reaction to socket.io messages $myelements . socket . on ( "message" , function onMessage ( message ) { if ( $el . data ( ) . templateScope === message . event ) { // Update element scope (maybe re-render) var scope = { } ; scope [ message . event ] = message . data ; $myelements . updateElementScope ( $el . get ( 0 ) , scope ) ; } // we forward socket.io's message as a jQuery event on the $el. $myelements . debug ( "forwarding backend message '%s' as jQuery event '%s' to element %s with data: %j" , message . event , message . event , $el . get ( 0 ) , message . data ) ; // Kludge: If jQuery's trigger received an array as second parameters // it assumes you're trying to send multiple parameters to the event handlers, // so we enclose message.data in another array if message.data is an array // sent from the backend  if ( $ . isArray ( message . data ) ) { $el . trigger ( message . event , [ message . data ] ) ; } else { $el . trigger ( message . event , message . data ) ; } } ) ; // Reaction on local events triggered on the element by jQuery $el . on ( "message" , function onElementMessageEvent ( jQueryEvent , message ) { if ( message . event === undefined || message . data === undefined ) { $myelements . debug ( "event key or data not present in second argument to trigger()" , message . event , message . data ) ; console . error ( "myelements.jquery: $.fn.trigger('message') must be called with an object having the keys 'event' and 'data' as second argument.  " ) ; return ; } $myelements . debug ( "Sending message '%s' to backend with data: %j" , message . event , message . data ) ; $myelements . socket . send ( message ) ; } ) ; }
Prepares HTML elements for being able to receive socket.io's messages
as jQuery events on the element
Prepares HTML elements for being able to receive socket . io s messages as jQuery events on the element