Giter Club home page Giter Club logo

form_slider's Introduction

FormSlider

jQuery UI Slider + Ruby on Rails Forms

Build Status

###Demo

Installation

Rails >= 3.2

Add this line to your application's Gemfile:

gem 'form_slider'

And then execute:

$ bundle

Add the jQuery ui slider library and form_slider.js to application.js:

//= require jquery
//= require jquery.ui.slider
//= require form_slider

Add the jquery ui css file to application.css:

*= require jquery.ui.slider

Usage

Form For

Use the slider_form_for builder instead of form_for, then use the slider_field helper to generate a slider with a label:

= slider_form_for @film do |f|
  .field
    = f.slider_field :rating, min: 0, max: 10, step: 1
  .field
    = f.submit "Send"

Form Tag

Use the slider_field_tag helper if you need to use a slider with form_tag:

= slider_form_tag "/buy_tickets" do
  .field
    = slider_form_tag :number_of_tickets, 1, min: 1, max: 6, step: 1
  .field
    = submit_tag "Send"

Formtastic Support

You can use form_slider with Formtastic's semantic_form_for:

= semantic_form_for @film do |f|
  = f.inputs do
    = f.input :rating, as: :slider, min: 0, max: 10, step: 1, color: 'red'

Field Options

Name Description Usage Default Value
min The minimum value of the slider = f.slider_field :name, min: 1 1
max The maximum value of the slider = f.slider_field :name, max: 10 10
disabled Disable input = f.slider_field :name, disabled: true false
step Determines the size or amount of each interval or step the slider takes between the min and max = f.slider_field :name, max: 10, step: 1 1
color Background color of the slider = f.slider_field :name, color: 'blue' 'white'
label Customize the slider's label. Pass false to have no label. :name is the labels name :append is the text that will be appended to the label, right after the value of the slider = f.slider_field :rate, label: { name: 'Rating:', append: 'out of 10' }, min: 1, max: 10, step: 1
value_display CSS selector of the html element that displays the slider's value. By default the slider's value will be displayed in the slider's label, so use this option only if you need to override this behavior. = f.slider_field :name, color: 'blue', value_display: '#slider-val'

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

form_slider's People

Contributors

yud avatar jrohrbaugh avatar jo-m avatar

Watchers

James Cloos 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.