rails.js的目的 [英] rails.js's purpose

查看:94
本文介绍了rails.js的目的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经熟悉Rails 3,UJS和JQuery.我了解为什么需要jquery.js和application.js,但为什么需要rails.js?

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?

推荐答案

将其视为jQuery和Rails之间缺少的链接.假设您有一个表单标签,

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>

将在这个表单标签上查看data-remote的代码以及Rails使用的其他此类属性,并通过AJAX提交此表单的代码由rails.js处理.它就像Rails和jQuery之间的连接器.来源非常简单,您可以在 https://github上阅读.com/rails/jquery-ujs/blob/master/src/rails.js

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

这篇关于rails.js的目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆