original_string: public function add_action_handler(component_action $action, $id = null) {
          if (!$id) {
              $id = html_writer::random_id($action->event);
          }
          $this->page->requires->event_handler("#$id", $action->event, $action->jsfunction, $action->jsfunctionargs);
          return $id;
      }
code: public function add_action_handler(component_action $action, $id = null) {
          if (!$id) {
              $id = html_writer::random_id($action->event);
          }
          $this->page->requires->event_handler("#$id", $action->event, $action->jsfunction, $action->jsfunctionargs);
          return $id;
      }
code_tokens: public function add_action_handler ( component_action $ action , $ id = null ) { if ( ! $ id ) { $ id = html_writer :: random_id ( $ action -> event ) ; } $ this -> page -> requires -> event_handler ( "#$id" , $ action -> event , $ action -> jsfunction , $ action -> jsfunctionargs ) ; return $ id ; }
docstring: Adds a JS action for the element with the provided id.
  
  This method adds a JS event for the provided component action to the page
  and then returns the id that the event has been attached to.
  If no id has been provided then a new ID is generated by {@link html_writer::random_id()}
  
  @param component_action $action
  @param string $id
  @return string id of element, either original submitted or random new if not supplied
docstring_tokens: Adds a JS action for the element with the provided id .