簡體   English   中英

未被捕獲的TypeError:$(…).tableDnD不是函數

[英]Uncaught TypeError: $(…).tableDnD is not a function

實際上,我正在嘗試使用c#開發一個拖放式gridview,我正在尋找一些諸如tableDnD之類的jquery庫,並在下面的示例中看到了一段代碼。 我正在嘗試用我的代碼回復它,但是我有一個

Uncaught TypeError: $(...).tableDnD is not a function.

我的代碼很簡單,我想解釋一下:

首先,這是具有以下代碼的母版頁:

<head runat="server">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   <title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js"></script>
<link rel="stylesheet" href="Styles/Coaching.css" type="text/css" />
  <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"/>

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous"/>

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="http://localhost:2848/js/jquery.tablednd.js" type="js/javascript">
</script>

 <script type="text/javascript">
    var strorder;
    $(document).ready(function () {
       $('#grdResultados').tableDnD(
       {
           onDrop: function (table, row) {
               reorder();
               $.ajax({
                   type: "POST",
                   url: "diagnostico-plantilla.aspx/GridViewReorders",
                   data: '{"Reorder":"' + strorder + '"}',
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   async: true,
                   cache: false,
                   success: function (msg) {
                       alert("Successfully Save ReOrder");
                   }

               })
           }
       }
       );
   });
   function reorder() {
       strorder = "";
       var totalid = $('#grdResultados tr td input').length;
       for (var i = 0; i < totalid; i++) {
           strorder = strorder + $('#grdResultados tr td input')[i].getAttribute("value") + "|";
       }
   }
</script>

如您所見,這是一個簡單的母版頁,那么aspx在這一行中我編寫了gridview

 <asp:GridView ID="grdResultados" runat="server" CssClass="table table-hover" AllowPaging="True" 
                            AllowSorting="True" AutoGenerateColumns="False" GridLines="None" DataKeyNames="id" DataSourceID="odsResultados" OnRowDataBound="grdResultados_RowDataBound" OnPageIndexChanged="grdResultados_PageIndexChanged" OnSorting="grdResultados_Sorting" OnRowCommand="grdResultados_RowCommand">

所以,為什么會有這個錯誤,因為當我嘗試進行拖放操作時,它不起作用,並且我使用了Chrome檢查器,並且遇到了這個問題。

非常感謝

替換此行:

<script src="http://localhost:2848/js/jquery.tablednd.js" type="js/javascript">

有了這個:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/plugins/jquery.tablednd.js"></script>

如果這解決了問題,則說明您未正確引用tablednd.js文件。向本地.js文件添加引用的最簡單方法是將其從Visual Studio-Solution Explorer拖動到頁面。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM