Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: e4902d7877
Fetching contributors…

Cannot retrieve contributors at this time

76 lines (43 sloc) 2.514 kB

Simple Datepicker Helper

Example with formtastic: = f.input :bathing_season_end, :as => :string, :input_html => {:class => "datepicker"}

This plugin is a Ruby on Rails helper for Eulerian Javascript Datepicker.

DEPENDENCIES

INSTALLATION

$ ruby script/plugin install git://github.com/rafaelp/simple_datepicker_helper.git

To be able to use the simple_datepicker methods below you need to include the javascript library file and CSS stylesheet in the of your layout template. You can do this either by manually including the files via a javascript_include_tag and a stylesheet_link_tag (the files are both named "simple_datepicker"), OR by using the included simple_datepicker_includes helper method, which will do this for you.

Attention: simple_datepicker.js must be called after prototype.js and scriptaculous.js

USAGE

simple_datepicker_for(field_id, options = {})

You can set $DATEPICKER_OPTIONS with default options in your initializers (or environment.rb)

EXAMPLE

Put default language in initializers/simple_datepicker_helper.rb

$SIMPLE_DATEPICKER_OPTIONS = {:language => 'pt'}

Put this code in your view:

<p>
    <label for="person_birthday">Birthday</label><br/>
    <%= text_field "person" , "birthday" %>
</p>
<%= simple_datepicker_for "person_birthday", {:keepFieldEmpty => true} %>

The following line will be generated:

<script type="text/javascript">
//<![CDATA[
var simple_datepicker_person_birthday = new DatePicker({"language": "pt", "relative": "person_birthday", "keepFieldEmpty": true});
//]]>
</script>

All options are available at:

http://www.eulerian.com/en/opensource/datepicker-prototype-scriptaculous

License

Simple Datepicker Helper is released under the MIT License.

AUTHOR

Rafael Lima

Working at BielSystems

Blog: http://rafael.adm.br

Podcast: http://rafael.adm.br/voltandopracasa

Github: http://github.com/rafaelp

Twitter: http://twitter.com/rafaelp

Did you like?

Recommend me at Working With Rails

Jump to Line
Something went wrong with that request. Please try again.