How to pass Ruby variables to a JavaScript function in a Rails view?

前端 未结 6 1554
一个人的身影
一个人的身影 2020-11-28 12:53

I\'m wondering what the best practice is for passing variables to JavaScript functions in a rails view. Right now I\'m doing something like:

<% content_f         


        
6条回答
  •  被撕碎了的回忆
    2020-11-28 13:22

    There's a technique called "unobtrusive javascript". Here's a Railscast about it: link text . It works both with prototype an jQuery. There are also plugins that can help simplify some of the tasks described in the article.

提交回复
热议问题