Tag Archives: Event

add_event()

Add event handler. A typical use of this method is to pass Select2 event name, then a Javascript event handler function. Note that the generated Javascript methods is injected BEFORE end of $(document).ready(…)

Signature:

public function add_event(param1, param2, ....)

Parameter:

  • variable-length argument lists

A list of supported events:

  • change
  • select2-opening
  • select2-open
  • select2-close
  • select2-highlight
  • select2-selecting
  • select2-removing
  • select2-removed
  • select2-loaded
  • select2-focus
  • select2-blur
  • select2-clearing

Example:

$pac -> add_event('select2-close', 'function() { console.log("close"); }');