Last active
April 3, 2018 07:15
-
-
Save maecha/655d17d2db14f610c145929e3f156a2c to your computer and use it in GitHub Desktop.
How to use DatePicker in AdminLTE ver2 (with Bootstrap 3.3.6)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: | |
: | |
//= require admin-lte/plugins/datepicker/bootstrap-datepicker | |
//= require admin-lte/plugins/datepicker/locales/bootstrap-datepicker.ja |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready -> | |
$('#hogeDateDatePicker').datepicker({ | |
format: 'yyyy/mm/dd', | |
language: 'ja', | |
todayHighlight: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= 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