ligerdateeditor -- format設定

來源:互聯網
上載者:User

今天對jqueryLigerUI外掛程式的日期展示,格式設定做個總結,搞了一下午總算是好了,記錄一下,希望能幫到其他人。


1. 外掛程式預設支援“yyyy-MM-dd hh:mm”格式,可通過設定showTime是否展示時間(預設不展示),如下源碼:

$.ligerDefaults.DateEditor = {        format: "yyyy-MM-dd hh:mm",        showTime: false,        onChangeDate: false,        absolute: true,  //選擇框是否在附加到body,並絕對位置        cancelable: true,      //可取消選擇        readonly: false              //是否唯讀    };

使用的時候,直接調用就可以了,如:

//初始化時間控制項
$("input[name='endTime']").ligerDateEditor();  // 2017-11-27

此時若想要展示時分秒,可通過設定format實現,即:

$("input[name='endTime']").ligerDateEditor({format: "yyyy-MM-dd hh", showTime : true,onChangeDate:function(){var test = this.getFormatDate(this.usedDate); //擷取指定時間$("input[name='endTime']").val(test + ":00"); //2017-11-27 15:00}});

getFormatDate是內建方法, usedDate是內建屬性,直接調用即可。通過onChangeDate方法,在指定日期的時候,可進行一些額外操作,如上,如不需要,可去掉。

樣本如下:

$("input[name='endTime']").ligerDateEditor({format: "yyyy-MM-dd"}); //2017-11-27$("input[name='endTime']").ligerDateEditor({format: "yyyy-MM-dd hh:mm:ss",showTime : true}); //2017-11-27 15:11:11$("input[name='endTime']").ligerDateEditor({showTime:true}); //2017-11-27 15:11


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.