i am making an UI for which i am using a pre build logic which is
function goto1(){
$('.fool .item').draggable({
revert:true,
proxy:'clone'
});
$('#cool .drop').droppable({
onDragEnter:function(){
$(this).addClass('over');
},
onDragLeave:function(){
$(this).removeClass('over');
},
onDrop:function(e,source){
$(this).removeClass('over');
if ($(source).hasClass('assigned')){
$(this).append(source);
} else {
var c = $(source).clone().addClass('assigned');
$(this).empty().append(c);
c.draggable({
revert:true
});
}
}
});
$('.fool').droppable({
accept:'.assigned',
onDragEnter:function(e,source){
$(source).addClass('trash');
},
onDragLeave:function(e,source){
$(source).removeClass('trash');
},
onDrop:function(e,source){
$(source).remove();
}
});
}
and it is called when i am dynamically generating the table where the element is to be dropped whose code is
function calldata(value) {
$('#goto').fadeOut('fast');
jQuery.ajax({
url: "data3.php",
type: 'post',
async: false, // why? Don't block your browser! Leave this out.
data: {value: value}, // key/value, so PHP finds your data as "value"
cache: false,
dataType: "json",
success: function(response) {
var p = 10;
var j = 0;
var m;
var z = "<table >"; // moved here
z = z + "<tr ><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>lunch</th><th>5</th><th>6</th><th>7</th><th>8</th></tr>";
// Note: z needs one more column (10 in total!)
var k = response.length;
if (k > 10) // remove this IF, you need a value in ALL cases.
m = k / 10;
for (var o = 0; o < m; o++) {
z = z + "<tr>";
for (j; j < p; j++) {
var obj = response[j];
var go = obj.subject;
var no= obj.color;
z = z + "<td class='drop'></td>";
}
z = z + "</tr>";
p = p + 10;
}
z = z + "</table>";
document.getElementById("cool").innerHTML = z;
}
});
goto1();
}
and this is my code for html where inside one div 'fool' i have static table and one div 'cool' where i am dynamically generating a table . if u want a link for the pre defined code i am using this as predefined js file js file
this above code is working fine if both table are static its not working if am generating one table dynamically.if anyone could tell me why it ould be of great help thanks in advance