Mulit jQuery UI Datepickers具有不同的设置
I am trying to show more than one datepicker with different settings on one page using jQuery UI.
我试图使用jQuery UI在一个页面上显示不同设置的多个日期选择器。
//Datepicker
$("input.date-picker").datepicker({
});
// Additional settings
$("input.date-picker.multi-calendars").datepicker({
numberOfMonths: 3
});
"//Additional settings" simply gets ignored and only the "//Datepicker" get applied despite setting the datepicker to show 3 months when it has the class .multi-calendars
.
“//其他设置”只是被忽略,只有“// Datepicker”被应用,尽管将datepicker设置为显示3个月时它有类.multi-calendars。
After hours of digging onto this, I found one solution. Remove the class hasDatepicker
from the UI library markerClassName: "hasDatepicker"
经过几个小时的挖掘,我找到了一个解决方案。从UI库markerClassName中删除类hasDatepicker:“hasDatepicker”
This fixed the problem, however, my month and year dropdown menus does not work anymore. When I click on the dropdown to pick a date or a year the whole datepicker just closes!
这解决了问题,但是,我的月份和年份下拉菜单不再起作用。当我点击下拉列表选择一个日期或一年时,整个日期选择器就会关闭!
So I looked into a way to fix this but to no avail.
所以我研究了解决这个问题的方法,但无济于事。
Is the UI datepicker really that limited? or its just me missing something?
UI datepicker真的有限吗?或者它只是我遗漏了什么?
Here is a live preview: http://loai.directory/test/test - its both inputs that has the label "Date picker".
这是一个实时预览:http://loai.directory/test/test - 它的两个输入都有“Date picker”标签。
1 个解决方案
#1
You have to use the second selector first.
您必须先使用第二个选择器。
DatePicker doesn't allow you to apply it twice on the same element, so you have to put specific datepicker selector first then more general ones that applies datepicker on other dp elements:
DatePicker不允许您在同一元素上应用它两次,因此您必须先将特定的datepicker选择器放在其他dp元素上应用datepicker的更通用的选择器:
// Additional settings
$("input.date-picker.multi-calendars").datepicker({
numberOfMonths: 3
});
//Datepicker
$("input.date-picker").datepicker({
});
更多相关文章
- 创建一个未排序的数组,其中包含重复元素和唯一元素的总和
- jQuery在元素内部检测mousedown,然后在元素外部进行mouseup
- 如何在angularjs代码中单元测试jquery元素
- jquery1.9+获取append后的动态元素
- Jquery | 基础 | 慕课网 | 元素选择器
- 如何知道DOM元素何时移动或调整大小
- 删除使用jQuery动态创建的元素
- 基于Jquery ui 可复用的酒店 web页面选择入住日期插件
- 如何在jQuery中选择最后一个子元素?