我有以下Javascript,它只适用于Chrome,我无法找出原因:
//makes appointments draggable
$("._ts").sortable({
connectWith: "._ts",
revert: "true",
cancel: ".new_appt",
stop: function(e){
var element = e.toElement;
var date = $(element).parents('.route_container').find('.date h2').html();
var timeslot = $(element).parents('.timeslot').attr('id');
var tAppt_id = $(element).attr('id');
console.log("Date:."+date);
console.log("time:."+timeslot);
console.log("route:."+tAppt_id);
$.ajax({
type: "post",
dataType: "json",
url: ajaxurl,
data:{action: "update_appointments", date: date, timeslot: timeslot, appt_id: tAppt_id},
success: function(response){
if(response.type == "success"){
console.log("Update appointment worked.");
console.log("Date:."+response.date);
console.log("time:."+response.timeslot);
console.log("route:."+response.timeslot);
$(this).parents('.delete_appt').hide();
}
}
});
}
});
问题在于变量date
,timeslot
和& tAppt_id
返回undefined
。这又适用于Chrome;但是,仅限Chrome。不能在IE或FF中工作。
我也尝试使用e.currentTarget
和e.relatedTarget
两种方法都没有效果。有人能告诉我我做错了什么吗?