UNPKG

2.37 kBMarkdownView Raw
1Unobtrusive scripting adapter for jQuery
2========================================
3
4This unobtrusive scripting support file is developed for the Ruby on Rails framework, but is not strictly tied to any specific backend. You can drop this into any application to:
5
6- force confirmation dialogs for various actions;
7- make non-GET requests from hyperlinks;
8- make forms or hyperlinks submit data asynchronously with Ajax;
9- have submit buttons become automatically disabled on form submit to prevent double-clicking.
10
11These features are achieved by adding certain ["data" attributes][data] to your HTML markup. In Rails, they are added by the framework's template helpers.
12
13Full [documentation is on the wiki][wiki], including the [list of published Ajax events][events].
14
15Requirements
16------------
17
18- [jQuery 1.8.x or higher][jquery];
19- HTML5 doctype (optional).
20
21If you don't use HTML5, adding "data" attributes to your HTML4 or XHTML pages might make them fail [W3C markup validation][validator]. However, this shouldn't create any issues for web browsers or other user agents.
22
23Installation using the jquery-rails gem
24------------
25
26For automated installation in Rails, use the "jquery-rails" gem. Place this in your Gemfile:
27
28```ruby
29gem 'jquery-rails'
30```
31
32And run:
33
34```shell
35$ bundle install
36```
37
38Require both `jquery` and `jquery_ujs` into your application.js manifest.
39
40```javascript
41//= require jquery
42//= require jquery_ujs
43```
44
45Installation using Bower
46------------
47
48Run `bower install jquery-ujs --save` to install the jquery-ujs package.
49
50Usage
51------------
52
53Require both `jquery` and `jquery-ujs` into your application.js manifest.
54
55```javascript
56//= require jquery
57//= require jquery-ujs
58```
59
60How to run tests
61------------
62
63Follow [this wiki](https://github.com/rails/jquery-ujs/wiki/Running-Tests-and-Contributing) to run tests .
64
65
66[data]: http://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes "Embedding custom non-visible data with the data-* attributes"
67[wiki]: https://github.com/rails/jquery-ujs/wiki
68[events]: https://github.com/rails/jquery-ujs/wiki/ajax
69[jquery]: http://docs.jquery.com/Downloading_jQuery
70[validator]: http://validator.w3.org/
71[csrf]: http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection.html
72[adapter]: https://github.com/rails/jquery-ujs/raw/master/src/rails.js