Datepicker

Datepicker for Bootstrap:

http://www.eyecon.ro/bootstrap-datepicker/

Bugs:

In bootstrap modal, if the popup shows on the top of input field could cause not clickable. To solve this, set property “orientation” to “top”

HTML

<link href="{{BASE_URL}}/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" />

<script src="{{BASE_URL}}/plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="{{BASE_URL}}/plugins/bootstrap-datepicker/locales/bootstrap-datepicker.zh-TW.min.js"></script>

Javascript

$('.datepicker').datepicker({
	autoclose: true, 
	clearBtn: true, 
	format: 'yyyy-mm-dd', 
	todayHighlight: true,
	language: 'zh-TW'
	//orientation: 'top'
});

Datepicker for jQuery UI:

$.fn.datepicker.dates['zh-TW'] = {
	days: ['日', '一', '二', '三', '四', '五', '六'],
	daysShort: ['日', '一', '二', '三', '四', '五', '六'],
	daysMin: ['日', '一', '二', '三', '四', '五', '六'],
	months: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
	monthsShort: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
	today: "今天",
	clear: "Clear",
	format: "yyyy-mm-dd",
	titleFormat: "MM yyyy", /* Leverages same syntax as 'format' */
	weekStart: 0
};

$('input.datepicker').datepicker({
	language: 'zh-TW'
});

 

Datepicker in boostrap modal and clone:

$form.find('.control-group.copy .datepick').each(function(index){
    var $this = $(this);
    //$this.datepicker('destroy');
    $this.attr("id", "").removeData().off();
    $this.find('.add-on').removeData().off();
    $this.find('input').removeData().off();

    $this.datepicker({
        format: 'yyyy-mm-dd'
    });
});

Set value for datepicker field by javascript
Need to execute update method

$form.find('[name="event_date"]').val(data.event_date)
            .datepicker('update');

Reference:

4 thoughts on “Datepicker

  1. This excellent website truly has all the info I needed about this subject and
    didn’t know who to ask.

  2. Un blog est un journal personnel en effet mais surtout un lieu d’échange et
    de partage d’idées (tout comme tu fais actuellement sur le
    sujet)

  3. hey there and thаnk you for your infoгmatіon ?
    Ӏ havе dеfinіtelу picκеd up something new from гight here.
    I diԁ alternаtivelу expertiѕe several teсhnicаl issuеs
    using this site, as I eхperiеnced
    to reload the ѕite a lоt of tіmes pгeѵious to I may juѕt gеt it tο loaԁ proρeгlу.
    I wеrе pοnԁеring if
    youг web hosting is OK? Not thаt I am cοmрlaining,
    but slow loаding instances occаsionѕ will often affect youг рlacement in goоgle anԁ сοuld damage your high quаlitу ranking if adѕ and marketіng with
    Adwoгds. Αnyωay I’m including this RSS to my email and can look out for much extra of your respective interesting content. Make sure you update this once more very soon

    My page :: Jacob

Comments are closed.