在 jquery 中实现可移动的
我正在尝试为我的应用程序构建动态拖放模块。
它包括一个表格,其中包含所有可放置的 div 和一些形状。
因为我无法提前知道某人将放入 div 中的形状类型,所以我必须保存用户选择将形状放入其中的一个或多个 div,我需要让应用程序非常动态...
我设法对所有单元格执行此操作,除了大正方形和长线的顶行以及大正方形和宽线的右列......
代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type=text/css>
.draggable { width: 20px; height: 20px; background-color:Blue;}
.draggable_big { width: 40px; height: 40px; background-color:Blue;}
.draggable_wide { width: 40px; height: 20px; background-color:Blue;}
.draggable_long { width: 20px; height: 40px; background-color:Blue;}
.droppable { width: 20px; height: 20px; background-color:Red;}
</style>
<script src="JavaScript/jquery-1.4.2.js" type="text/javascript"></script>
<script src="JavaScript/jquery-ui-1.8.4.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$(".draggable").draggable({ snap: '.droppable' });
$(".draggable_big").draggable({ snap: '.droppable' });
$(".draggable_wide").draggable({ snap: '.droppable' });
$(".draggable_long").draggable({ snap: '.droppable' });
$(".droppable").droppable({
drop: function() {alert('dropped:' + $(this).attr('id')); }
});
});
</script>
</head>
<body dir="rtl">
<form id="form1" runat="server">
<div style="position:absolute; top:0; right:100px">
<table border="1" cellpadding="0" cellspacing="0">
<tr id="tr_1" runat="server">
<td id="td_1_1" runat="server"><div id="1_1" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_1_2" runat="server"><div id="1_2" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_1_3" runat="server"><div id="1_3" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_1_4" runat="server"><div id="1_4" class="droppable"></div></td> ***not getting responce for draggable_big***
</tr>
<tr id="tr_2" runat="server">
<td id="td_2_1" runat="server"><div id="2_1" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_2_2" runat="server"><div id="2_2" class="droppable"></div></td>
<td id="td_2_3" runat="server"><div id="2_3" class="droppable"></div></td>
<td id="td_2_4" runat="server"><div id="2_4" class="droppable"></div></td>
</tr>
<tr id="tr_3" runat="server">
<td id="td_3_1" runat="server"><div id="3_1" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_3_2" runat="server"><div id="3_2" class="droppable"></div></td>
<td id="td_3_3" runat="server"><div id="3_3" class="droppable"></div></td>
<td id="td_3_4" runat="server"><div id="3_4" class="droppable"></div></td>
</tr>
<tr id="tr_4" runat="server">
<td id="td_4_1" runat="server"><div id="4_1" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_4_2" runat="server"><div id="4_2" class="droppable"></div></td>
<td id="td_4_3" runat="server"><div id="4_3" class="droppable"></div></td>
<td id="td_4_4" runat="server"><div id="4_4" class="droppable"></div></td>
</tr>
</table>
</div>
<div style="position:absolute; top:0; right:50px">
<div class="draggable"></div>
<div class="draggable"></div>
<div class="draggable"></div>
<div class="draggable"></div>
<div class="draggable_big"></div>
<div class="draggable_wide"></div>
<div class="draggable_long"></div>
</div>
</form>
</body>
</html>
任何人都知道问题是什么?
谢谢
I am trying to build a dynamic drag&drop module for my App.
It includes a table that holds all the droppable divs and few shapes.
As i can't know from advance the type of shape someone will put in a div and i have to save the div or divs which the user chose to drop the shape in i need to allow the app to be very dynamic...
I managed to do it for all the celld except from the top row for the big square and the long line and the right column for the big square and for a wide line....
The code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type=text/css>
.draggable { width: 20px; height: 20px; background-color:Blue;}
.draggable_big { width: 40px; height: 40px; background-color:Blue;}
.draggable_wide { width: 40px; height: 20px; background-color:Blue;}
.draggable_long { width: 20px; height: 40px; background-color:Blue;}
.droppable { width: 20px; height: 20px; background-color:Red;}
</style>
<script src="JavaScript/jquery-1.4.2.js" type="text/javascript"></script>
<script src="JavaScript/jquery-ui-1.8.4.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$(".draggable").draggable({ snap: '.droppable' });
$(".draggable_big").draggable({ snap: '.droppable' });
$(".draggable_wide").draggable({ snap: '.droppable' });
$(".draggable_long").draggable({ snap: '.droppable' });
$(".droppable").droppable({
drop: function() {alert('dropped:' + $(this).attr('id')); }
});
});
</script>
</head>
<body dir="rtl">
<form id="form1" runat="server">
<div style="position:absolute; top:0; right:100px">
<table border="1" cellpadding="0" cellspacing="0">
<tr id="tr_1" runat="server">
<td id="td_1_1" runat="server"><div id="1_1" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_1_2" runat="server"><div id="1_2" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_1_3" runat="server"><div id="1_3" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_1_4" runat="server"><div id="1_4" class="droppable"></div></td> ***not getting responce for draggable_big***
</tr>
<tr id="tr_2" runat="server">
<td id="td_2_1" runat="server"><div id="2_1" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_2_2" runat="server"><div id="2_2" class="droppable"></div></td>
<td id="td_2_3" runat="server"><div id="2_3" class="droppable"></div></td>
<td id="td_2_4" runat="server"><div id="2_4" class="droppable"></div></td>
</tr>
<tr id="tr_3" runat="server">
<td id="td_3_1" runat="server"><div id="3_1" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_3_2" runat="server"><div id="3_2" class="droppable"></div></td>
<td id="td_3_3" runat="server"><div id="3_3" class="droppable"></div></td>
<td id="td_3_4" runat="server"><div id="3_4" class="droppable"></div></td>
</tr>
<tr id="tr_4" runat="server">
<td id="td_4_1" runat="server"><div id="4_1" class="droppable"></div></td> ***not getting responce for draggable_big***
<td id="td_4_2" runat="server"><div id="4_2" class="droppable"></div></td>
<td id="td_4_3" runat="server"><div id="4_3" class="droppable"></div></td>
<td id="td_4_4" runat="server"><div id="4_4" class="droppable"></div></td>
</tr>
</table>
</div>
<div style="position:absolute; top:0; right:50px">
<div class="draggable"></div>
<div class="draggable"></div>
<div class="draggable"></div>
<div class="draggable"></div>
<div class="draggable_big"></div>
<div class="draggable_wide"></div>
<div class="draggable_long"></div>
</div>
</form>
</body>
</html>
Any one have any idea what is the problem?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过添加以下内容解决了问题:
到每个可拖动对象..
10x
solved the problem by adding:
to every draggable object..
10x