Shouldn’t I be able to call this CoffeeScript method from within an erb template? It’s not working but it seems like it should.
setup.js.coffee
class SetupStepTwo
include @
constructor: ->
@resetView()
resetView : ->
console.log('cool');
window.ns1.SetupStepTwo = SetupStepTwo
$ ->
new SetupStepTwo()
update.js.erb
window.ns1.SetupStepTwo.resetView();
Your
SetupStepTwoclass has an instance method calledresetViewbut you’re trying to call it as a class method (or at least what passes as a class method in (Java|Coffee)Script) when you say this:If you really want to use
resetViewas a class method then your class should look more like this:The
@on@resetViewmakes a class method and@constructoris, more or less, likeself.classin Ruby.Demo: http://jsfiddle.net/ambiguous/eDdmd/
If you want
resetViewto be an instance method then you’ll need to replace this:with a
resetViewcall on an instance ofSetupStepTwo.