rails.js's purpose

岁酱吖の 提交于 2019-12-12 00:38:24

问题


I am getting acquainted with Rails 3, UJS and JQuery. I understand why jquery.js and application.js are needed but why is rails.js needed?


回答1:


Think of it as the missing link between jQuery and Rails. Suppose you have a form tag,

<form method="POST" action="/some/path" data-remote="true">
  ..
</form>

The code that will look at the data-remote on this form tag and other such attributes used that Rails looks at, and submit this form through AJAX is handled by rails.js. It is like a connector between Rails and jQuery. The source is rather simple which you can read at https://github.com/rails/jquery-ujs/blob/master/src/rails.js



来源:https://stackoverflow.com/questions/6645583/rails-jss-purpose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!