GithubHelp home page GithubHelp logo

josh / rails-behaviors Goto Github PK

View Code? Open in Web Editor NEW
272.0 10.0 18.0 1 MB

Rails UJS Behaviors for jQuery and Zepto

Home Page: http://josh.github.com/rails-behaviors/

License: MIT License

Ruby 5.00% CoffeeScript 92.91% JavaScript 0.73% Shell 0.64% HTML 0.71%

rails-behaviors's Introduction

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.

rails-behaviors's People

Contributors

ayrton avatar foca avatar gf3 avatar josh avatar lachlanjc avatar mastahyeti avatar mislav avatar nextmat avatar semanticart avatar sstephenson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.