示例#1
0
function AddAutoCompleteToFields(Bvb_Grid_Event $event)
{
    $subject = $event->getSubject();
    $script = "\$(document).ready(function() {";
    foreach ($subject->getVisibleFields() as $name) {
        $script .= "\$(\"input#filter_{$name}\").autocomplete({focus: function(event, ui) " . "{document.getElementById('filter_{$name}').value = ui.item.value }," . " source: '{$subject->getAutoCompleteUrlForFilter($name)}'});\n";
    }
    $script .= "});";
    $subject->getView()->headScript()->appendScript($script);
}
示例#2
0
 /**
  *
  * @param string $name Event name
  * @param array  $data Data to be passed to object
  *
  * @return void
  */
 public function emit(Bvb_Grid_Event $event)
 {
     if (isset($this->_listeners[$event->getName()])) {
         $code = $this->_listeners[$event->getName()];
         $priority = array();
         foreach ($code as $key => $pri) {
             $priority[$key] = $pri['priority'];
         }
         array_multisort($priority, SORT_ASC, $code);
         foreach ($code as $callback) {
             $eventParams = array_merge_recursive($event->getParams(), $callback['params']);
             $event->setParams($eventParams);
             call_user_func($callback['callback'], $event);
         }
     }
 }