rails-behaviors

Rails UJS Behaviors for jQuery and Zepto

  • 所有者: josh/rails-behaviors
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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 <josh@joshpeek.com>

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

主要指标

概览
名称与所有者josh/rails-behaviors
主编程语言CoffeeScript
编程语言Ruby (语言数: 5)
平台
许可证MIT License
所有者活动
创建于2011-10-27 00:38:48
推送于2015-06-05 16:39:40
最后一次提交2015-06-05 09:39:38
发布数18
最新版本名称v0.8.4 (发布于 )
第一版名称v0.1.0 (发布于 )
用户参与
星数268
关注者数9
派生数18
提交数252
已启用问题?
问题数0
打开的问题数0
拉请求数14
打开的拉请求数0
关闭的拉请求数3
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?