/**
  * Binds a handler to one or more events (like click) for each matched element.
  * Can also bind custom events.
  *
  * @param DOMNode|PhpQueryObject|string $document
  * @param unknown_type $type
  * @param unknown_type $data Optional
  * @param unknown_type $callback
  *
  * @TODO support '!' (exclusive) events
  * @TODO support more than event in $type (space-separated)
  * @TODO support binding to global events
  */
 public static function add($document, $node, $type, $data, $callback = null)
 {
     phpQuery::debug("Binding '{$type}' event");
     $documentID = phpQuery::getDocumentID($document);
     //		if (is_null($callback) && is_callable($data)) {
     //			$callback = $data;
     //			$data = null;
     //		}
     $eventNode = self::getNode($documentID, $node);
     if (!$eventNode) {
         $eventNode = self::setNode($documentID, $node);
     }
     if (!isset($eventNode->eventHandlers[$type])) {
         $eventNode->eventHandlers[$type] = array();
     }
     $eventNode->eventHandlers[$type][] = array('callback' => $callback, 'data' => $data);
 }
 public function dumpTree($html = true, $title = true)
 {
     $output = $title ? 'DUMP #' . phpQuery::$dumpCount++ . " \n" : '';
     $debug = phpQuery::$debug;
     phpQuery::$debug = false;
     foreach ($this->stack() as $node) {
         $output .= $this->__dumpTree($node);
     }
     phpQuery::$debug = $debug;
     print $html ? nl2br(str_replace(' ', ' ', $output)) : $output;
     return $this;
 }