简体   繁体   English

rails.js 的目的

[英]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.

相关问题 Laravel 5.2与rails.js-删除引发TokenMismatchException - Laravel 5.2 with rails.js - DELETE throws TokenMismatchException Rails、webpacker:在什么地方/什么时候在类中使用 import 语句,以及在 pack/application.js 中要求的目的是什么? - Rails, webpacker: where/when to use the import statement in classes, and what's the purpose of requiring in the pack/application.js? 节点js中的流程退出事件的目的是什么? - What's the purpose of the process exit event in node js? 这个JS模式的目的是什么? - What is the purpose of this JS pattern? 参数的目的 - Parameter's purpose “ Pro JavaScript Techniques”的JS addEvent函数实现中的这部分代码的目的是什么? - What's the purpose of this part of code in this JS addEvent function implementation of “Pro JavaScript Techniques”? Rails 7 中 .js.erb 的替代品是什么? - What's the replacement for .js.erb in Rails 7? | \\ s的目的/作用是什么? 在([\\ s \\ S] + | \\ s?) - What is the purpose/effect of |\s? in ([\s\S]+|\s?) backbone.js 的目的是什么? - What is the purpose of backbone.js? 在three.js的ExtrudeGeometry.UVGenerator.generateSideWallUV中条件语句的目的是什么? - What is the purpose of the conditional statement in three.js's ExtrudeGeometry.UVGenerator.generateSideWallUV?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM