function InicializarObjectoPositicion(){ var container = document.getElementById('container1'), element = document.getElementsByClassName('text')[0]; // options var options = { limit: container, setCursor: true }; // initialize drag new Draggable(element, options); } function NuevoObjectoInicial(){ var num = 0; $( ".text" ).draggable({ containment: '#container1', scroll: false, stop: function(event, ui) { num+= 1; if (num == 1){ $("#firma_visible #Formato_Visible .text").hide(); $('#dataX').val(0); $('#dataY').val(0); }else{ $('#dataX').val(ui.position['left']); $('#dataY').val(ui.position['top']); } }, }); } var transferred = false; $('.text').draggable({ connectToSortable: "div#container1", helper: 'clone', start: function(event, ui) { $(this).hide(); }, stop: function(event, ui) { if(!transferred) { $(this).show(); } else{ $(this).remove(); transferred = false; } } }); $('div#container1').sortable({ connectWith: "div#container1", receive: function(event, ui) { transferred = true; $("#firmar-documento").removeAttr('disabled'); InicializarObjectoPositicion() NuevoObjectoInicial(); } });