jQuery DatePicker OnSelect事件太早发生 [英] jQuery DatePicker OnSelect Event Fired too early

查看:187
本文介绍了jQuery DatePicker OnSelect事件太早发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$("#div-calendar").datepicker({ onSelect: SelectedDay });

function SelectedDay(date, inst) {
    var s = inst.dpDiv.find('.ui-datepicker-current-day a').parent().attr("class");
    alert(s);

}

我试图获得点击的日期/单元格的类

Im trying to get the class of the clicked date/cell.

问题是事件在类更改之前发生,所以它总是会显示我之前点击的类。我会需要OnSelected而不是任何想法?

The Problem is the Event happens BEFORE the class change, so it will always show me the classes of the previous click. I would need "OnSelected" instead.. any ideas?

推荐答案

一个丑陋的黑客我曾经诉诸于过去:

An ugly hack I've resorted to using in the past:

$("#div-calendar").datepicker({ onSelect: SelectedDay });

function SelectedDay(date, inst) {
    // HACK: the ui hasn't been updated yet, check later
    window.setTimeout(function() {
        var s = inst.dpDiv.find('.ui-datepicker-current-day a').parent().attr("class");
        alert(s);
    }, 0);
}

这篇关于jQuery DatePicker OnSelect事件太早发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆