【发布时间】:2014-05-07 06:34:25
【问题描述】:
我有以下 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 都不起作用。有人可以告诉我我做错了什么吗?
【问题讨论】:
标签: jquery jquery-ui internet-explorer google-chrome