Ember.BuDateRange
Summary
Bootstrap时间日期选择插件,可配置的参数有
$('input[name="daterange"]').daterangepicker(
{
format: 'YYYY-MM-DD',
startDate: '2013-01-01',
endDate: '2013-12-31'
},
function(start, end, label) {
alert('A date range was chosen: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
}
);
//第一个参数为DateRange组件的配置项,第二个参数为值改变后的回调函数,可利用该回调函数进行dom操作等
可选的options参数有
startDate: (Date object, moment object or string) 起始日期,值可以为一个Date类型对象或moment类型对象
endDate: (Date object, moment object or string) 结束日期,值可以为一个Date类型对象或moment类型对象
minDate: (Date object, moment object or string) 可供选择的最小日期,值可以为一个Date类型对象或moment类型对象
maxDate: (Date object, moment object or string) 可供选择的最大日期,值可以为一个Date类型对象或moment类型对象
dateLimit: (object) 起始到结束最大的日期区间,(moment时间区间)
showDropdowns: (boolean) Show year and month select boxes above calendars to jump to a specific month and year
showWeekNumbers: (boolean) Show week numbers at the start of each week on the calendars
timePicker: (boolean) 是否允许具体时间选择
timePickerIncrement: (number) Increment of the minutes selection list for times (i.e. 30 to allow only selection of times ending in 0 or 30)
timePicker12Hour: (boolean) Use 12-hour instead of 24-hour times, adding an AM/PM select box
ranges: (object) Set predefined date ranges the user can select from. Each key is the label for the range, and its value an array with two dates representing the bounds of the range
opens: (string: 'left'/'right') Whether the picker appears aligned to the left or to the right of the HTML element it's attached to
buttonClasses: (array) CSS class names that will be added to all buttons in the picker
applyClass: (string) CSS class string that will be added to the apply button
cancelClass: (string) CSS class string that will be added to the cancel button
format: (string) Date/time format string used by moment when parsing or displaying the selected dates
separator: (string) Separator string to display between the start and end date when populating a text input the picker is attached to
locale: (object) Allows you to provide localized strings for buttons and labels, and the first day of week for the calendars
singleDatePicker: (boolean) Show only a single calendar to choose one date, instead of a range picker with two calendars; the start and end dates provided to your callback will be the same single date chosen
parentEl: (string) jQuery selector of the parent element that the date range picker will be added to, if not provided this will be 'body'
组件使用方式为
{{bu-daterange startDate=startDate endDate=endDate}}
Item Index
Methods
_attachEvent
Syntax
_attachEvent
()
private
Summary
添加事件监听
_parseOptions
Syntax
_parseOptions
()
private
Summary
如果options是模板中传入的字符串,尝试将字符串转换为options对象
_prepareDate
Syntax
_prepareDate
()
private
Summary
如果已经设置了开始日期和结束日期,则将值设置入options中
_updateDom
Syntax
_updateDom
()
private
Summary
在视图渲染完成后将对象转换为DateRange组件
change
Syntax
change
()
private
Summary
在对象发生改变时,设置开始日期与结束日期
Properties
endDate
Syntax
endDate
String
Summary
结束日期
Default: null
startDate
Syntax
startDate
String
Summary
开始日期
Default: null