Van*_*ani 10 c# asp.net jquery
嗨,我想将丢弃的项目的位置保存到数据库[aspx,javascript].用户可以删除任意数量的项目,调整大小并删除[隐藏],最后当他们点击"保存"按钮时,它应该保存到数据库中.我有代码在drop/stop中执行此操作,但它将保存我想要仅在最后阶段保存的所有丢弃的项目.我想很多开发人员应该已经这样做了,所以请建议一些代码.
$(function() {
$('#frame img').live('mousemove', function(event) {
$('#frame img').resizable().parent().draggable();
});
});
$(function() {
$('#frame img').live('dblclick', function(event) {
// $(this).resizable("destroy") not working
$(this).hide();
//$(this).unbind("resizable"); not working
//$(this).removeclass(); not working
});
});
$(document).ready(function() {
//Counter
counter = 0;
//Make element draggable
$("img").draggable({
helper: 'clone',
containment: '#frame',
//When first dragged
stop: function(ev, ui) {
var pos = $(ui.helper).offset();
objName = "#clonediv" + counter
$(objName).css({ "left": pos.left, "top": pos.top });
$(objName).removeClass("drag");
//When an existiung object is dragged
$(objName).draggable({
containment: 'parent',
stop: function(ev, ui) {
var pos = $(ui.helper).offset();
}
});
}
});
//Make element droppable
$("#frame").droppable({
drop: function(ev, ui) {
if (ui.helper.attr('id').search(/drag[0-9]/) != -1) {
var pos = $(ui.helper).offset();
counter++;
var element = $(ui.helper).clone();
//var element = element1.resizable();
element.addClass("tempclass");
$(this).append(element);
$(".tempclass").attr("id", "clonediv" + counter);
//$(".tempclass").attr("onclick",function(){ $(this).remove(););
$("#clonediv" + counter).removeClass("tempclass");
//Get the dynamically item id
draggedNumber = ui.helper.attr('id').search(/drag([0-9])/)
itemDragged = "dragged" + RegExp.$1
//console.log(itemDragged)
//alert('left' + pos.left + ',top' + pos.top + 'of item' + itemDragged);
$("#clonediv" + counter).addClass(itemDragged);
}
}
});
//Make the element resizable
});
Run Code Online (Sandbox Code Playgroud)
如果有任何问题,请纠正我.提前致谢
一种方法可能是将拖动停止处的坐标放入隐藏字段中,然后您可以在后面的代码中读取该字段并将其存储在数据库中。
当您重新渲染页面时,您还需要填充字段并使用 javascript 将对象放回原来的位置。
另外,提及您正在使用的语言背后的代码可能会很方便。C#、PHP、Java,什么?