Skip to content

Instantly share code, notes, and snippets.

@maecha
Last active April 3, 2018 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maecha/655d17d2db14f610c145929e3f156a2c to your computer and use it in GitHub Desktop.
Save maecha/655d17d2db14f610c145929e3f156a2c to your computer and use it in GitHub Desktop.
How to use DatePicker in AdminLTE ver2 (with Bootstrap 3.3.6)
:
:
//= require admin-lte/plugins/datepicker/bootstrap-datepicker
//= require admin-lte/plugins/datepicker/locales/bootstrap-datepicker.ja
$(document).ready ->
$('#hogeDateDatePicker').datepicker({
format: 'yyyy/mm/dd',
language: 'ja',
todayHighlight: true
});
class HogesController < ApplicationController
def new
@hoge = Hoge.new
end
def create
# something...
if @hoge.save
redirect_to root_path,
flash: { success: 'Succeed in creating data.' }
else
flash.now[:alert] = 'Failed in creating data.'
render 'new', locals: { date: Time.zone.now.strftime('%Y/%m/%d') } # Plz change the variable 'date' as you like
end
end
end
= form_for @hoge, url: hoges_path do |f|
= f.text_field :date,
id: 'hogeDateDatePicker',
class: 'form-control',
placeholder: '2018/01/31',
value: @date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment