Giter Site home page Giter Site logo

markmagnus / bootstrap_datepicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from derekstavis/bootstrap_datepicker

0.0 1.0 0.0 165 KB

Rails 3 plugin that allows you to select dates from a calendar using Twitter Bootstrap as default theme

Ruby 100.00%

bootstrap_datepicker's Introduction

Bootstrap Datepicker Rails plugin

This gem allows you to use a beautifull twitter-bootstrap themed date picker on date fields via a simple form helper.

This gem packs Stefan Petre’s amazing jQuery/Bootstrap plugin (www.eyecon.ro/bootstrap-datepicker/) with a simple Rails interface.

Getting Started

for Rails >= 3.1:

  1. Insert into your Gemfile:

    gem 'bootstrap_datepicker'
    
  2. If you are using Rails 3.1 with the asset pipeline enabled (default), the necessary files are already in your asset pipeline.

Just add (if they are not already there) to your app/assets/javascripts/application.js:

//= require jquery
//= require jquery-ujs
//= require jquery-ui
//= require twitter/bootstrap
//= require bootstrap-datepicker

The same applies for app/assets/stylesheets/application.css

*= require bootstrap-datepicker

Usage

Add this to your view.

<%= datepicker_input "user", "birthday" %>

Where “user” is your model name and “birthday” the name of the datefield.

You can also use it with the form helper like:

<% form_for(@user) do |f| %>
  <%= f.datepicker 'birthday' %>
  <%= f.submit 'Create' %>
<% end %>

Nested attributes are permitted as well:

<% form_for(@user) do |f| %>
  <% f.fields_for(@nested) do |f2| %>
    <%= f2.datepicker 'birthday' %>
  <% end %>
  <%= f.submit 'Create' %>
<% end %>

You can pass options as it would be a normal text_field, plus all the datepicker options available (www.eyecon.ro/bootstrap-datepicker/)

<%= datepicker_input(:foo, :att1,
        :format => 'mm/dd/yy',
        :week_start => 0, 
        :view_mode => 'years', 
        :min_view_mode => 'days') %>

Support

Open an issue in github.com/derekstavis/bootstrap_datepicker if you need further support or want to report a bug

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.