下面给出的函数工作正常,但是我希望每个元素都可以放大s可调整大小但是只要我双击该元素就会丢失可调整大小的属性。 我该如何解决?
function dropTag(tag){
var box = "";
var hashtag = "#"+tag;
$(hashtag).draggable({
helper:'clone'
});
// alert("tag0:"+tag+"box:"+box);
$('#droppable').droppable({
drop: function(ev,ui){
var tmp = $(ui.draggable).attr("id");
// alert("in droppable1:"+tmp);
// alert("tag:"+tag+"box:"+box);
if (tmp=="TaskName_div"){
box= '<div id="TaskName_dummy'+count3+'" class ="TaskName_div_dummy" ondblclick="EditText(this.id);" >'+
'<input type=checkbox id="task_name_checkbox_dummy'+count3+'"/>'+
'Task dummy</div>';
count3++;
}
if (tmp=="Normal_Tag2_div"){
box = '<div id="Normal_Tag2_div_dummy'+count2+'"class ="Normal_Tag2_div_dummy" ondblclick="EditText(this.id);">'+ WM_LANG_NORMAL_TAG2+'</div>';
count2++;
}
if (tmp=="Normal_Tag1_div"){
box = '<div id="Normal_Tag1_div_dummy'+count1+'"class ="Normal_Tag1_div_dummy" ondblclick="EditText(this.id);">'+WM_LANG_NORMAL_TAG+ '</div>';
count1++;
}
// alert("tmp:"+tmp+"box:"+box);
if(($(ui.draggable).attr("id")).indexOf("dummy",0)==-1){
$(box)
.appendTo('#droppable' )
.draggable({
collide: 'block',
revert: 'invalid'
}).resizable({
resize:function(ev,ui)
{
tag_width=ui.size.width;
tag_height=ui.size.height;
}
}).dblclick(function (ev,ui)
{
var response = $.ajax({
type:"POST",
url: "grabImage.php",
data:"name=John&location=Boston&function_name=img",
complete: function(msg){
var resp = msg.responseText;
if(msg && msg.readyState != 4) {
alert("Ready State :"+msg.readyState); return;
}
else{
//wb_load();
alert( "Data Saved: " + resp);
}
}
});
}
);
tag_left=(ui.position.left);
tag_top=(ui.position.top);
//alert(tag_left+";"+tag_top);
//tag_height=ui.originalSize.height;
// tag_width=ui.originalSize.width;
//alert(tag_width);
//alert("tag_left"+tag_left+"tag_top"+tag_top+"tag_height"+tag_height+"tag_width"+tag_width);
}
else{
// alert("not dropped:"+tag);
tag_left=(ui.position.left);
tag_top=(ui.position.top);
//alert(tag_left+";"+tag_top);
//tag_height=ui.originalSize.height;
//tag_width=ui.originalSize.width;
//alert("tag_left"+tag_left+"tag_top"+tag_top+"tag_height"+tag_height+"tag_width"+tag_width);
}
}
});
}
答案 0 :(得分:1)
这有效
$(function() {
$('#frame img').live('mousemove', function(event) {
$('#frame img').resizable().parent().draggable();
});
});