What is the best way to use jQuery plugins like datepicker, chosen, etc in batman.js? I found data-mixin helper, but there is no documentation and examples with about how to use it. Also I found this issue: https://github.com/Shopify/batman/issues/199, but again I can’t get it work, because it also undocumented.
Ideally I want to do something like this:
#helpers/application_helper.js.coffee
datePicker: (field) ->
$(field).datepicker()
#some_view.html
<input data-helper="datePicker" ... >
I haven’t used them yet. However, I think you should be able to use the “Really after afterFilters” afterFilters. Which are the afterFilers, but they’ve recently been revamped so they’ll fire after the DOM has been rendered.
And by looking at the tests you should be able to specify them for an action. This should apply you to be DRY and only have the code in an afterFilter for specific actions.