i'm Italian and i'm sorry form my english... I'm a new "web developer"...I have built a drag and drop page with jquery. I'd like to add a button that enable/disable the jquery script (i.e. the possibility to do drag and drop). Moreover I'd like to save the dom modification so that the user sees the last modification at each subsequent access. Hope i'm clear in my explanation. Thanks in advance.
here my js script:
var sourceElement;
var transferred = false;
$("#sortable li").draggable({
helper: 'clone',
revert: 'invalid',
cursor: 'move',
connectToSortable: "#panchina",
start: function (event, ui) {
$(this).hide();
sourceElement = $(this).text().toString();
},
stop: function (event, ui) {
if(!transferred)
$(this).show();
else
{
$(this).remove();
transferred = false;
}
}
});
$("#panchina li").sortable({
receive: function(event, ui)
{
transferred = true;
}
});
$("#sortable, #panchina li, .bg-success, .bg-info, .bg-warning, .bg-danger").droppable({
drop: function (event, ui) {
$(ui.draggable).appendTo(this);
}
});
$("#save").click(function() {
// empty string to save the result
/*var dataList = "";*/
var dataList= new Array();
var panchina= new Array();
// find all li elements within the element with the id list
var $entries = $("#433").find('li');
var $panchinari =$('#panchina').find('li');
$entries.each(function(i, entry) {
dataList[i] = $(entry).text().toString();
});
$panchinari.each(function(i, entry) {
panchina[i] = $(entry).text().toString();
});
});