Using Rails 3.1, where do you put your “page specific” JavaScript code?

前端 未结 29 2118
一生所求
一生所求 2020-11-22 11:08

To my understanding, all of your JavaScript gets merged into 1 file. Rails does this by default when it adds //= require_tree . to the bottom of your appl

29条回答
  •  故里飘歌
    2020-11-22 11:28

    Paloma project offers interesting approach to manage page specific javascript code.

    Usage example from their docs:

    var UsersController = Paloma.controller('Users');
    
    // Executes when Rails User#new is executed.
    UsersController.prototype.new = function(){
       alert('Hello Sexy User!' );
    };
    

提交回复
热议问题