Last Updated: February 25, 2016
·
1.832K
· adamyanalunas

Re-fire one-shot events in Batman.js

If you use Batman.js as a front-end framework then you know the documentation is horrible. By now you'll also know that the "ready" state on a view is a one-shot event that never gets re-fired, even if the view's HTML or contents are changed out – calling view.fire 'ready' simply does nothing.

Unless you use this undocumented but public reset method resetOneShot:

someView = new Batman.View
# ... snip, but imagine "ready" was already fired ...
someView.fire 'ready' # Does nothing
someView.event('ready').resetOneShot()
someView.fire 'ready' # 'ready' event is fired

The only reasonable way to learn how to actually use Batman.js is to pour through the source code and the tests. Really, the tests are where you'll get some useful information.

2 Responses
Add your response

Good looking out. Thanks.

Come downtown sometime and I'll buy you a beer.

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside