3
我有以下的JavaScript来的工作,并且只在Chrome的工作,而且我想不通为什么:toElement似乎只在Chrome,IE不FF或
//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
都没有工作。有人能告诉我我做错了什么吗?
这就是它的人!感谢您的帮助! – BlackHatSamurai
我刚刚意识到,你给我的答案获得了原点元素,我将如何获得项目被删除的元素? – BlackHatSamurai
根据[documentation](http://api.jqueryui.com/sortable/#event-stop)它将来自处理程序的'ui.item'第二个参数'stop:function(e,ui){'。 –