0

当用户单击事件的日期时,我想打开一个 URL。我使用 jQuery UI Datepicker,但我看不出问题出在哪里。

这是我的代码:

<script>
$(document).ready(function() {
    var events = [

        {
        Title: "titre",
        Idevent: "1",
        Date: new Date("05/20/2012")},
    {
        Title: "test24",
        Idevent: "3",
        Date: new Date("06/14/2012")}
    ];
    $("#calendarcaps").datepicker({
        beforeShowDay: function(date) {
            var result = [true, '', null];
            var matching = $.grep(events, function(event) {
                return event.Date.valueOf() === date.valueOf();
            });

            if (matching.length) {
                result = [true, 'highlight', null];
            }

            return result;
        },
        onSelect: function(dateText) {
            var date, selectedDate = new Date(dateText),
                i = 0,
                event = null;

            while (i < events.length && !event) {
                date = events[i].Date;

                if (selectedDate.valueOf() === date.valueOf()) {
                    event = events[i];
                }

                i++;
            }

            if (event) {
                window.location.href = "test.php?id=" + event.Idevent;
            }
        }
    });
});​
</script>

谁能看到我做错了什么?

4

0 回答 0