How do you limit CoffeeScript (or JavaScript) execution to a particular controller and action in Rails 3.1?

前端 未结 5 701
攒了一身酷
攒了一身酷 2021-01-02 09:50

The new Rails 3.1 asset pipeline is really nice, but since all CoffeeScript (or JavaScript) files get melded down into a single file that is included in every page, it raise

5条回答
  •  臣服心动
    2021-01-02 10:40

    Why not to put the javascript for the particular controller as a view on this controller (as they correspond there if are so specific)?

    If they are general enaugh you can mark your view with classes, ids or data (html5) and make your javascript look for that (so you can reuse your code).

提交回复
热议问题