我正在使用Connected sort able列表来实现两个列表框之间的拖放功能。如何找到所选元素(或拖动后第二个列表框中的列表项)并将其发送到后面的代码,以便我可以将其保存到数据库中。我正在使用Linqdatasource进行数据库操作。我的java脚本是 -
$(function () {
$("#Setter,#Getter").sortable({
connectWith: ".sortable",
recieve: function (e, ui)
{
var item = (this).valueOf("Section");
}
});
我的清单如下 -
<asp:ListView ID="Listview1" runat="server" DataSourceID="LinqDataSource1" >
<LayoutTemplate>
Unallocated Sections <br />
<asp:Label ID="SetterCount" runat="server"></asp:Label>
<ul class="sortable" draggable="true" id="Setter" style="overflow: scroll; empty-cells: hide; height: 500px; width: 200px; border: solid 1px; background: #b6b6b6;" >
<li id="Li1" runat="server" draggable="true" >
<asp:PlaceHolder ID="PlaceHolder1" id-="itemPlaceholder" runat="server" ></asp:PlaceHolder>
</li>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li id="Li2" runat="server" title="Drag to Allocate sections" >
<%# Eval("Section")%>
</li>
</ItemTemplate>
</asp:ListView>
</td>
<td>
<asp:Repeater ID="Repeater" runat="server" DataSourceID ="LinqDataSource6">
<HeaderTemplate><ul class="sortable" draggable="true" id="Getter" style="overflow: scroll; empty-cells: hide; height: 500px; width: 200px; border: solid 1px; background: #b6b6b6;" ></HeaderTemplate>
<ItemTemplate>
<li id ="lI2" runat ="server">
<%# DataBinder.Eval(Container.DataItem, ("Section"))%>
</li>
</ItemTemplate>
<FooterTemplate></ul></FooterTemplate>
</asp:Repeater>
</td>
</tr>
});
答案 0 :(得分:0)
$(function(){
$("Getter,Setter").sortable({
connectWith: ".sortable",
update: function (event, ui) {
alert("New position: " + (ui.item.index() + 1));
alert(ui.item.text());
}
});
});