How do you create javascript functions that are available project-wide in Ruby on Rails?

前端 未结 7 1531
攒了一身酷
攒了一身酷 2020-12-25 14:05

I put the following function in my application.js:

function test() {
  alert(\"See Me\")
}

classrooms/_new_small.html.haml:



        
7条回答
  •  孤城傲影
    2020-12-25 14:23

    Simple solution, remove escape_javascript, but it's dangerous see Why escape_javascript before rendering a partial? . Currently you want to execute

    $('#test_container').html("
    

    which is converted into

    $('#test_container').html("
    
                                     
                  
提交回复
热议问题