after_save および<コード> before_save コールバックメソッドをBatman.jsのコールバックメソッドにコールするのは何ですか？ 私はRailsが提供するものに似たものを探しています。
What is the correct to call
before_save callbacks methods in batman.js? I'm looking for something similar to what rails provides.
Check out this blog post: http://rmosolgo.github.io/blog/2014/03/19/batman-dot-model-lifecycle-callbacks/
Hope it helps!
I just looked into this myself. I found that a nice way to get this functionality was to put a listener on the record as soon as it was constructed, taking advantage of the Model's lifecycle:
class App.Thing extends Batman.Model constructor: -> super # instantiates the record @get('lifecycle').onEnter 'save', => console.log('about to save!') @get('lifecycle').onExit 'save', => console.log('just saved!') @ # return the record
This isn't documented much yet, but you can see the full record lifecycle (steps, names, order, etc!) described in the tests!</div