Repository is archived
No commit activity in last 3 years
No release in over 3 years
A jQuery plugin to facilitate the handling of form field dependencies.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0

Runtime

 Project Readme

RailsDependsOn

Gem Version

A simple rails engine to make it easier to use the great DependsOn jQuery Plugin:

http://dstreet.github.io/dependsOn/

Note: not all the features of the original plugin are implemented for now

Installation

Add this line to your application's Gemfile:

gem 'rails_depends_on'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails_depends_on

Include the assets in your javascript manifest file:

//= require dependent-fields to your Javascript manifest file (usually found at app/assets/javascripts/application.js).

Usage

 = f.input 'a_checkbox'
.depends-on{"data-id" => 'a_checkbox', 'data-value' =>'true'}
  = f.input 'another_field'
 = f.input 'a_text_field'
.depends-on{"data-id" => 'a_text_field', 'data-value' =>[['1'],['2']]}
  = f.input 'another_field'
 = f.input 'a_text_field'
.depends-on{"data-id" => 'a_text_field', 'data-qualifier'=> 'not', 'data-value' =>[['1'],['2']]}
  = f.input 'another_field'
 = f.input 'a_multiple_select'
.depends-on{"data-id" => 'a_multiple_select', 'data-qualifier'=> 'contains', 'data-value' =>[['1'],['2']]}
  = f.input 'another_field'
 = f.input 'a_text_field'
.depends-on{"data-id" => 'a_text_field', 'data-qualifier'=> 'email', 'data-value' => 'true'}
  = f.input 'another_field'
 = f.input 'a_text_field'
.depends-on{"data-id" => 'a_text_field', 'data-qualifier'=> 'url', 'data-value' => 'true'}
  = f.input 'another_field'
 = f.input 'a_text_field'
.depends-on{"data-id" => 'a_text_field', 'data-qualifier'=> 'match', 'data-value' => '\da{3}'}
  = f.input 'another_field'
 = f.input 'a_radio_buttone'
.depends-on{"data-name" => 'a_radio_button', 'data-qualifier'=> 'match', 'data-value' => ['1','2']}
  = f.input 'another_field'

TODO

  • Multiple dependencies
  • Regexp qualifier
  • Custom Qualifiers
  • implement all dependsOn options (callbacks etc..)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/francescob/rails_depends_on.

License

The gem is available as open source under the terms of the MIT License.