I am creating new div's in seating chart, but the will not become draggable after they have been inserted.
Maybe someone can shine a light on it and make my new dynamically created div draggable.
$(document).ready(function() {
$("#addSeat").bind("click", function(e){
$.getJSON("getrecord.php?format=raw&ticketid=1",
function(data){
$(".seat-element").clone(true).removeAttr("id").attr("id", data.id).appendTo("#glassbox").html(data.seatid).css({ "top": "10px", "left": "10px"});
});
});
});
Thanks Christopher, can you tell me how to do this?
This is my draggable code:
$(document).ready(function () {
$(".seat-element").draggable({
containment: '#glassbox',
scroll: false
}).mousemove(function(){
var coord = $(this).position();
$("p:last").text( "left: " + coord.left + ", top: " + coord.top );
}).mouseup(function(){
var coords=[];
var currentId = $(this).attr('id');
//alert(currentId);
var coord = $(this).position();
var item={ coordTop: coord.left, coordLeft: coord.top, coordId: currentId };
coords.push(item);
var order = { coords: coords };
$.post('updatecoords.php', 'data='+$.toJSON(order), function(response){
if(response == "success")
$("#respond").html('<div class="success"style="text-align:center;">Seat Position has been saved to the database.</div>').hide().fadeIn(1000);
setTimeout(function(){ $('#respond').fadeOut(2000); }, 2000);
});
});
});