• This repository has been archived on 09/Nov/2017
  • Stars
    star
    271
  • Rank 151,717 (Top 3 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created about 13 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rails UJS Behaviors for jQuery and Zepto

Rails Behaviors (Deprecated)

Rails Behaviors implements the data-* behaviors generated by Rails 3.x.

This is an alternative to 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 if you want to use the gem version.

Installation

rails-behaviors is distributed through the bower package manager.

bower install rails-behaviors

Testing

For testing you will need:

  • Ruby 1.9.3+
  • Bundler (gem install bundler)
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 for a markup and event reference.

Contributing

Setup:

$ git clone git://github.com/josh/rails-behaviors.git
$ cd rails-behaviors/
$ bundle install

Run tests:

$ rackup -p 3000 test/config.ru
$ open http://localhost:3000/

License

Copyright © 2011 Joshua Peek <[email protected]>

Rails Behaviors is distributed under an MIT-style license. See LICENSE for details.

More Repositories

1

css-explain

SQL EXPLAIN for CSS selectors
JavaScript
1,069
star
2

selector-set

JavaScript
279
star
3

selector-observer

Allows you to monitor DOM elements that match a CSS selector
JavaScript
217
star
4

jquery-selector-set

JavaScript
215
star
5

overcast-sonos

Listen to your Overcast podcasts on Sonos.
PHP
183
star
6

nack

Node powered Rack server
CoffeeScript
172
star
7

Aware

A simple menubar app for OSX and macOS that tracks how long you've been actively using your computer
Swift
145
star
8

launchdns

A launchd friendly development DNS server
Shell
75
star
9

dotfiles

My $HOME
Shell
63
star
10

imdb-trakt-sync-broken

Sync IMDb to Trakt
Shell
53
star
11

scroll-anchoring

Preserves the user's scroll position while DOM mutations change the page.
HTML
50
star
12

tickerd

A Docker process scheduler
Go
12
star
13

swift-har

A Swift library for encoding, decoding, recording and testing using the HTTP Archive format.
Swift
10
star
14

icloud-backup-utils

Scripts creating backups of iCloud data.
Shell
8
star
15

google-domains-ddns

Dockerfile
7
star
16

workflows

Reusable workflows for GitHub Actions
6
star
17

smtp2webhook

SMTP to Webhook Relay
Go
6
star
18

csv2json

A humble CSV tool, friend of jq
Swift
6
star
19

displayrcd

Run a script when your Mac changes displays
Swift
5
star
20

offlineimap-gmail

Dockerfile
3
star
21

trakt-plex-sync

Sync Trakt history to Plex library
Python
3
star
22

homeassistant-healthchecks

Home Assistant custom component for Healthchecks.io
Python
3
star
23

josh

My GitHub profile
2
star
24

wikidatabots

Wikidata bots running under Josh404Bot
Python
2
star
25

docker-ondemand

Lazily start and automatically stop Docker for Mac
Shell
2
star
26

ConsoleKit

An embeddable SwiftUI OSLog view
Swift
2
star
27

homebrew-tap

Homebrew custom formulas for @josh repositories.
Ruby
2
star
28

mixnmatch-catalogs

Python
2
star
29

itunes-library-export

A command line tool to export iTunes Library XML files.
Swift
2
star
30

wikidata-api-schemas

Wikidata JSON Schemas
Shell
1
star
31

joshpeek.com

Just a bunch of redirects
Dockerfile
1
star
32

smtp2workflow

SMTP to GitHub Actions workflow Relay
Go
1
star
33

us-state-travel-advisories-feeds

JSON feeds for U.S. Department of State Travel Advisories
Python
1
star
34

alamo-drafthouse-feeds

JSON feeds for Alamo Drafthouse showings
Python
1
star
35

overcast-data

Overcast podcast personal data scraper
Python
1
star
36

imdb-plex-sync

Sync IMDb watchlist to Plex watchlist
Python
1
star
37

imdb-data

IMDB personal lists and ratings data scaper
Python
1
star