我想知道是否有人可以帮我解决我的jquery datepicker代码问题。 我在shopify中更改了主题,现在这个日期选择器没有提供日历视图。它只有一个文本框(甚至不是日期)。谢谢!
{{ 'http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css' | stylesheet_tag }}
{{ '//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js' | script_tag }}
<div style="width:300px; clear:both;">
<p>
<label for="date{{i}}">Delivery Date of {{ item.title }} (Please allow at least 2 days for delivery):</label>
<input id="date{{i}}" type="text" name="attributes[date{{i}}]" value="{{ cart.attributes.date }}" onkeyup="d_date.value=this.value" class="required" data-error="Please tell us which date you want your delivery for" />
<input type="hidden" id="d_date" name="properties[date]" />
<span style="display:block" class="instructions"> </span>
</p>
</div>
<script>
jQuery(function() {
jQuery("#date{{i}}").val("").datepicker({ minDate: 2,
beforeShowDay: nonWorkingDates,
numberOfMonths: 1,
minDate: 2,
maxDate: '+2M',
firstDay: 7
});
function noSunday(date){
var day = date.getDay();
return [(day > 0), ''];
};
function nonWorkingDates(date) {
var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
var closedDates = [[1, 1, 2014], [12, 25, 2013]];
var closedDays = [[Saturday], [Sunday]];
for (var i = 0; i < closedDays.length; i++) {
if (day == closedDays[i][0]) {
return [false];
}
}
for (i = 0; i < closedDates.length; i++) {
if (date.getMonth() == closedDates[i][0] - 1 &&
date.getDate() == closedDates[i][1] &&
date.getFullYear() == closedDates[i][2]) {
return [false];
}
}
return [true];
}
});
</script>
答案 0 :(得分:0)
谢谢你的帮助斯蒂芬。 我终于通过很多问题发现我在Shopify中使用的主题不支持产品页面中的日期选择器。我不知道为什么会这样。它确实支持日期选择器片段。仅限于每个产品页面。