[英]rails.js's purpose
I am getting acquainted with Rails 3, UJS and JQuery.我开始熟悉 Rails 3、UJS 和 JQuery。 I understand why jquery.js and application.js are needed but why is rails.js needed?
我明白为什么需要 jquery.js 和 application.js 但为什么需要 rails.js?
Think of it as the missing link between jQuery and Rails.将其视为 jQuery 和 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.将查看此表单标签上的
data-remote
和 Rails 查看的其他此类属性,并通过 AJAX 提交此表单的代码由 rails.js 处理。 It is like a connector between Rails and jQuery.它就像 Rails 和 jQuery 之间的连接器。 The source is rather simple which you can read at https://github.com/rails/jquery-ujs/blob/master/src/rails.js
源代码相当简单,您可以在https://github.com/rails/jquery-ujs/blob/master/src/rails.js阅读
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.