jquery datepicker选择今天
“我使用带有 onSelect 回调函数的内联 JQuery UI 日期选择器。此函数将多个日期的选定日期收集到数组中。我的问题是,日期选择器在启动时调用此函数并选择今天,并将其添加到我的数组中。我怎样才能禁用此行为?我不需要知道今天是哪一天,不想将其自动添加到我的数组中...
预先感谢您的帮助!
编辑:这是我的(非常简单)onSelect 回调按要求:
var blocked_days = new Array([..]);
function updateSelected(dateText)
{
var toAdd = true;
for (var i in blocked_days)
{
if (dateText == blocked_days[i])
{
blocked_days[i] = null;
toAdd = false;
}
}
if (toAdd === true)
blocked_days[blocked_days.length] = dateText;
$("#special_offer_blocked_form_blockeddays").val(blocked_days.join());
}
"im using an inline JQuery UI datepicker with an onSelect callback function. This function collects selected dates in an array for multiple dates. My problem is that datepicker calls this function on startup with selecting today, and adding it to my array. How can I disable this behaviour? I dont need to know which day is today, don't want to add it to my array automatically...
Thanks in advance for nay help!
Edit: Here's my (pretty simple) onSelect callback as requested:
var blocked_days = new Array([..]);
function updateSelected(dateText)
{
var toAdd = true;
for (var i in blocked_days)
{
if (dateText == blocked_days[i])
{
blocked_days[i] = null;
toAdd = false;
}
}
if (toAdd === true)
blocked_days[blocked_days.length] = dateText;
$("#special_offer_blocked_form_blockeddays").val(blocked_days.join());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有 onSelect 回调函数的代码吗?
解决这个问题的一种方法是通过检查来更新回调函数,以检查日期是否不是今天。如果不是,则添加日期。
如果您可以提供 onSelect 代码的示例,我将非常乐意查看并添加此代码?
更新:
然后您可以做的是每次调用该函数时设置一个简单的计数器,始终忽略第一次调用。
尝试一下,看看是否有效?
Have you got your code for the onSelect callback function?
One way around it would be to update the callback function with a check that checks that the date is not today. If it isn't then add the date.
If you can provide an example of your onSelect code I will be more than happy to take a look and add this?
Update:
What you could do then is set a simple counter each time the function is called, always ignoring the first call.
Try that and see if that works?