Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/josh/rails-behaviors
Rails UJS Behaviors for jQuery and Zepto
https://github.com/josh/rails-behaviors
Last synced: about 2 months ago
JSON representation
Rails UJS Behaviors for jQuery and Zepto
- Host: GitHub
- URL: https://github.com/josh/rails-behaviors
- Owner: josh
- License: mit
- Archived: true
- Created: 2011-10-27T00:38:48.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2015-06-05T16:39:40.000Z (over 9 years ago)
- Last Synced: 2024-07-08T20:07:37.537Z (3 months ago)
- Language: CoffeeScript
- Homepage: http://josh.github.com/rails-behaviors/
- Size: 1000 KB
- Stars: 272
- Watchers: 10
- Forks: 18
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rails Behaviors (Deprecated)
Rails Behaviors implements the `data-*` behaviors generated by Rails 3.x.
This is an alternative to [jquery-ujs](https://github.com/rails/jquery-ujs). First, it is all CoffeeScript goodness — well, that's mostly good for me! Second, it is written in a modular fashion. This makes it possible to cherry pick the components you need and replace specific functionaly without having to rewrite the entire library. Third, it uses built-in global ajax events rather than adding its own. O, one more thing, **Zepto**.
## Dependencies
**jQuery 1.7.2+** or **Zepto 0.8+**
You'll need [Sprockets 2](https://github.com/sstephenson/sprockets) if you want to use the gem version.
## Installation
rails-behaviors is distributed through the [bower](https://github.com/twitter/bower) package manager.
``` bash
bower install rails-behaviors
```## Testing
For testing you will need:
* Ruby 1.9.3+
* Bundler (`gem install bundler`)``` bash
bundle install
bundle exec rackup -E test ./test/config.ru
# now open the browser at http://localhost:9292
```## Migrating from jquery-ujs
This library handles all the `data-*` behaviors defined in Rails, so it is roughly feature for feature identicial in your Views.
The differences are in the JavaScript.
1. There are no `ajax:*` events. jQuery already has global ajax events built in, so there is no point in duplicating that functionality. Doing a find and replace for `"ajax:"` events should give you a good start. You're looking to replace `ajax:success` with `ajaxSuccess`, `ajax:error` with `ajaxError`, etc.
2. There are no global configuration options. Theres no equivalent for `$.rails`. You probably should have never used that in the first place.**NOTE:** You **cannot** use `rails-behaviors` and `jquery-ujs` at the same time.
## Reference
See [josh.github.com/rails-behaviors](http://josh.github.com/rails-behaviors/) for a markup and event reference.
## Contributing
Setup:
$ git clone git://github.com/josh/rails-behaviors.git
$ cd rails-behaviors/
$ bundle installRun tests:
$ rackup -p 3000 test/config.ru
$ open http://localhost:3000/## License
Copyright © 2011 Joshua Peek <>
Rails Behaviors is distributed under an MIT-style license. See LICENSE for details.