diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2015-02-22 14:40:39 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2015-02-22 14:40:39 +0100 |
commit | 7e47015224e778aa1bac45346665f1854b1ce4dc (patch) | |
tree | b875e8087042ee64993880686f5bb5633d383553 | |
parent | 4b2e055187f2f33d14f9e7573ce34b9333b553a3 (diff) | |
download | svg.js-7e47015224e778aa1bac45346665f1854b1ce4dc.tar.gz svg.js-7e47015224e778aa1bac45346665f1854b1ce4dc.zip |
Added example in Readme about passing additional data to events
-rwxr-xr-x | README.md | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -2642,6 +2642,18 @@ function whenSomethingHappens() { } ``` +You can also pass some data to the event: + +```javascript +function whenSomethingHappens() { + rect.fire('my:event', {some:'data'}) +} + +rect.on('my:event', function(e) { + alert(e.detail.some) // outputs 'data' +}) +``` + _Important: always make sure you namespace your event to avoid conflicts. Preferably use something very specific. So `wicked:event` for example would be better than something generic like `svg:event`._ ## Numbers |