开发者

Moving rails javascript to public while keeping ruby code?

I have a project to move some JS code outside of rails into the public direcotry, but some of it has ruby code embedded, and depends on the values of the variables from the controller开发者_JAVA百科s to set some of its code. How can I move it out of the view and still maintain the same structure, or do I need to just rewrite the JS from scratch?


You could move the core JavaScript code out of the view, and modify it such that anything that is a ruby variable is now passed as an input. Then from your view pages, just call the externalized JS using ruby code to pass in input values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜