Skip to content

Instantly share code, notes, and snippets.

@jendiamond
Last active April 1, 2016 18:07
Show Gist options
  • Select an option

  • Save jendiamond/461781a5f3ab89573f6c to your computer and use it in GitHub Desktop.

Select an option

Save jendiamond/461781a5f3ab89573f6c to your computer and use it in GitHub Desktop.

Date / Time Pickers

intialize it first

views/jobby_jobs/show.html.erb
.strftime("%a, %b %d")

views/jobby_jobs/index.html.erb
.strftime("%a, %b %d, %y")


RESUME

jobby_job.js.coffee

jQuery ->

$('#jobby_job_resume_to_be_sent').datepicker
  dateFormat: 'yy-mm-dd'

$('#jobby_job_resume_actually_sent').datepicker
  dateFormat: 'yy-mm-dd'

Gemfile

gem 'jquery-ui-rails'

application.js

$(document).on("page:load ready", function(){
    $("input.datepicker").datepicker();
});

INTERVIEW

jobby_job.js.coffee

$('#jobby_job_interview').datetimepicker({
    locale: 'ru'})
  <div class="three columns">
    <div class="field">
      <%= f.label :interview %><%= f.text_field :interview, 'data-behaviour' => 'datepicker' %>
      <span class="input-group-addon">
        <span class="glyphicon glyphicon-calendar"></span>
      </span>
    </div>
  </div>

===

Gemfile

gem 'momentjs-rails', '>= 2.9.0'
gem 'bootstrap3-datetimepicker-rails', '~> 4.17.37'

application.js

$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
    $(this).datepicker({"format": "yyyy-mm-dd", "weekStart": 1, "autoclose": true})
});


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment