Structuring coffeescript code?

后端 未结 5 1036
花落未央
花落未央 2020-12-09 01:46

Under Rails 3.1, I\'m trying to find out how to move a few coffeescript classes away from my controller default coffeescript file (home.js.coffee) into another

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 02:29

    You can also do it like this:

    @app = window.app ? {}
    
    app.Foo = Foo
    

    This will make app contain all your global classes, and window.app ? {} makes sure that you will only create one app.

提交回复
热议问题