How to get date from jquery date picker using droppable

I am trying to get date from Jquery ui date-picker by dropping some events in a calendar cell.

as soon as I have omitted some events in the calendar, it should show an alert displaying the date that I deleted the event.

$(".ui-datepicker-calendar tbody tr td").droppable({
    drop: function (event, ui) {
        // $("#datepicker").datepicker._selectDay('#datepicker',2,2012, this);
        alert('Event added <show dropped date>#####');
    }
});

      

Can anyone help me?

+3


source to share


1 answer


If you instantiate the droppable when the drag starts, you can just fire the click event on the transition.

The dropped date will be available using the normal method getDate

.



$(".event").draggable({
    start: function () {
        $(".ui-datepicker-calendar td").droppable({
            drop: function() {
                $(this).click();
                var theDate = $(".datepicker").datepicker("getDate");
                alert( "Event Created on " + theDate.toDateString() );
            }
        });
    }
});

      

I had a bit of trouble dragging myself around to act on such small areas, so I had to position the cursor using cursorAt

. Take a look at jsFiddle to see.

0


source







All Articles