AJAX 呼び出しを行った後、jQuery が機能しないという問題があります。これは正しく動作するドラッグ アンド ドロップ スクリプトですが、AJAX を呼び出したいときに停止します。
var ary1=new Array(5);
ary1[0]="container1";
ary1[1]="container2";
ary1[2]="container3";
ary1[3]="container4";
ary1[4]="main_container";
var ary2=new Array(5)
ary2[0]=0;
ary2[1]=0;
ary2[2]=0;
ary2[3]=0;
ary2[4]=4;
var i;
var srouce,dest;
var old;
$(window).load(function(){
$(function() {
$( ".draggable" ).draggable();
$( ".droppable, #droppable-inner" ).droppable({
activeClass: "ui-state-hover",
hoverClass: "ui-state-active",
drop: function( event, ui ) {
//if(ui.draggable.parent().attr('id')=="container1")alert("Yep");
alert(ui.draggable.attr('id') + ' was dropped from ' + ui.draggable.parent().attr('id')+' into '+$(this).attr('id'));
$( this ).addClass( "ui-state-highlight" );
// Move the dragged element into its new container
srouce= ui.draggable.parent().attr('id');
dest=$(this).attr('id');
for(i=0;i<5;i++){
if(srouce==ary1[i])break;} // to get src
alert(ary1[i]);
if((ary2[i]>0&&ary2[i]<=4&&ary1[i]=="main_container")|| (ary2[i]==1&&ary1[i]!="main_container"))
{
old=i;
ary2[i]--;
alert(ary2[i]); // decrement flag
for(i=0;i<5;i++){
if(ary1[i]==dest)break;}//to get dest
alert(ary1[i]);
if((ary2[i]==0&&ary1[i]!="main_container")|| (ary2[i]>=0&&ary2[i]<4&&ary1[i]=="main_container"))
{
ary2[i]++;//increment flag
alert(ary2[i]);
ui.draggable.attr('style','position:relative ;cursor:hand');// move the image
$(this).append(ui.draggable);
}
else
{
ary2[old]++;
ui.draggable.attr('style','position:relative ;cursor:hand');
ui.draggable.parent().append(ui.draggable);
}
}
return false;
}
});
});
});//]]>