2012-10-09 27 views
0

我是Jquery的新手,我試圖按照這篇文章Jquery Example來設置,但我無法拖動我的項目。林不知道我做錯了什麼。我的代碼如下。謝謝,在DataList控件上實現jQuery可排序

<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> 
+0

你收到任何JavaScript錯誤? – zgood

+0

沒有,當我看着螢火蟲(控制檯窗口)我沒有得到任何錯誤。我想我可能會附加到錯誤的父項。 $(「#<%= dlProcessList.ClientID%> tbody」)。sortable({ – Princess

回答

1

試試這個:

加「//」到你的腳本進口,像這樣:

<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(); 
}); 

看看是否能得到它的工作。

+0

我剛剛嘗試過,並沒有解決它,我只是讓文本顯示並且不會排序 – Princess

+0

您是否正在導入jQuery和jQuery UI可排序腳本? – zgood

+0

是的, 在頭 – Princess