在DataList控件上实现Jquery Sortable

时间:2012-10-09 18:16:20

标签: jquery jquery-ui

我是Jquery的新手,我正在尝试按照这篇文章Jquery Example来设置这个,但我无法拖动我的项目。我不确定我做错了什么。我的代码如下。谢谢,

<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>

$(function () {
   $("#<%=dlProcessList.ClientID %> tbody").sortable({
       handle: ".handle",
       placeholder: 'ui-state-highlight',
       cursor: 'move',
       start: function (event, ui) {
           ui.placeholder.height(ui.helper.height());
       }
   }).disableSelection();
});        

<asp:DataList ID="dlList" runat="server" >
  <HeaderTemplate>
      <tbody>
  </HeaderTemplate>

  <ItemTemplate>
       // My Data to display
  </ItemTemplate>  

  <FooterTemplate>
      </tbody>
  </FooterTemplate>
</asp:DataList>

2 个答案:

答案 0 :(得分:2)

试试这个:

在脚本导入中添加“//”,如下所示:

<script src="//code.jquery.com/jquery-1.8.2.js"></script>
<script src="//code.jquery.com/ui/1.9.0/jquery-ui.js"></script>

同时删除所有可排序的选项,只使用默认值来查看是否可以使其正常工作......

改变这个:

$(function () {
   $("#<%=dlList.ClientID %> tbody").sortable({
       handle: ".handle",
       placeholder: 'ui-state-highlight',
       cursor: 'move',
       start: function (event, ui) {
           ui.placeholder.height(ui.helper.height());
       }
   }).disableSelection();
}); 

对此:

$(function () {
    $("#<%=dlList.ClientID %> tbody").sortable();
});

看看是否有效。

答案 1 :(得分:2)