特定の要素にドラッグ アンド ドロップ機能を追加する必要があるページがあります。ドロップ イベントが発生すると、php 関数への ajax 呼び出しが行われ、div の内容が更新されます。ドラッグ アンド ドロップ用に jQueryUI を使用して jQuery を使用し、PHP フレームワークとして CakePHP を使用しています (これが関連するかどうかはわかりません)。
Firefox、Safari、さらには IE でもすべて正常に動作していますが、Opera または Chrome では、div の内容は更新されません (ただし、PHP 関数からのアクションは実行されます)。
だから、ここにコードがあります:
jQuery('#lists div').
filter(function() {return this.id.match(/item[\d]+_[\d]+/);}).
each(function() { jQuery(this).draggable( {axis: 'y'}); });
jQuery('#lists div').
filter(function() {
return this.id.match(/list[\d]+/);}).
each(function() {
jQuery(this).droppable({
drop: function(event, ui) {
dropID = jQuery(event.target).attr('id');
dragID = jQuery(ui.draggable).attr('id');
itemID = dragID.substr(dragID.lastIndexOf('_') + 1);
oldListID = dragID.substr(4).replace(/_[\d]+/g, '');
newListID = drop.substr(4);
jQuery.ajax({
url: "/lists/itemToList/"+itemID+"/"+oldListID+
"/"+newListID,
type: "POST",
success: function (data) {
jQuery('#lists').html(data);}
});
}
});
});
基本的に成功関数は実行されませんが、(エラーイベントで) errorThrown を見ようとすると「未定義」です