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.
Written by Adam Yanalunas
Related protips
2 Responses
This function is now documented :) http://batmanjs.org/docs/api/batman.event.html#prototype_function_resetoneshot
over 1 year ago
·
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
Best
#Batman.js
Authors
sirkitree
4.239K
adamyanalunas
1.441K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#