w2utils.bindEvents

Binds events found as data-* tags to the current object
bindEvents(selector, subject)
selector string, selector where to inspect data-* properties
subject object, this subject should have correct methods
This function allows you to define events in HTML and then bind them to the object. It is used internally for all of the objects to avoid using inline events with JavaScript as it is a potential security volnurability. Most recent Content Security Policies (CSP) have a quick qay to disable inline JavaScript.
For eample if you have a div defined in HTML as You can bind events to a custom object in the folliwing way The general format is Here is the list of events that you can use
  • click
  • dblclick
  • mouseenter
  • mouseleave
  • mouseover
  • mouseout
  • mousedown
  • mousemove
  • mouseup
  • focus
  • blur
  • input
  • change
  • keydown
  • keyup
  • keypress
Here is the list of predefined methods you can use
  • alert - for testing purporse, displays a js alert
  • stop - calls event.stopPropagation()
  • prevent - calls event.preventDefault()
  • stopPrevent - calls event.stopPropagation() and event.preventDefault()
Here is the list of predefined argumnets you can use
  • event - js event object
  • this - current object

User Comments

comments powered by Disqus