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?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- Carriage Return (ASCII chr 13) is missing from tex
- Question marks after images and js/css files in ra
- How to fix IE ClearType + jQuery opacity problem i
Think of it as the missing link between jQuery and Rails. Suppose you have a form tag,
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