]> source.dussan.org Git - svg.js.git/commitdiff
Added example in Readme about passing additional data to events
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>
Sun, 22 Feb 2015 13:40:39 +0000 (14:40 +0100)
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>
Sun, 22 Feb 2015 13:40:39 +0000 (14:40 +0100)
README.md

index 698a0abf836392a2f5d1ce957da14d470fa7bc32..935493265fb46e399e381545dfabc2858a2cd2fd 100755 (executable)
--- a/README.md
+++ b/README.md
@@ -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