Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 最简单表排序_Jquery_Asp.net Mvc_Razor - Fatal编程技术网

Jquery 最简单表排序

Jquery 最简单表排序,jquery,asp.net-mvc,razor,Jquery,Asp.net Mvc,Razor,我试图为我的MVC项目做一个尽可能简单的表排序,并在这里找到了这个很好的参考,尽管它似乎对我不起作用:(这里也有一个JSFIDLE测试,它当然有效(),但我的不会 这就是我要整理的桌子 <table id="projectTable"> <thead> <tr> <th id="name_header"> Name </th>

我试图为我的MVC项目做一个尽可能简单的表排序,并在这里找到了这个很好的参考,尽管它似乎对我不起作用:(这里也有一个JSFIDLE测试,它当然有效(),但我的不会

这就是我要整理的桌子

<table id="projectTable">
    <thead>
        <tr>
            <th id="name_header">
                Name
            </th>
            <th id="author_header">
                Author
            </th>
            <th>
                Date Created
            </th>
            <th>
                Date Edited
            </th>
            <th style="text-align:right;"> <a href="@Url.Action("Create", "Project")"><button>&nbsp;Create&nbsp;</button></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model) {
            var id = item.ProjectID;

            <tr id='@id' class="trow @if (System.Web.HttpContext.Current.Session["_SelectedProject"].ToString() == "System.Object") { <text>none</text> }
                            else
                            { if (id == (int)System.Web.HttpContext.Current.Session["_SelectedProjectID"]) {<text>highlighted</text> }}">
                <td>
                    @Html.DisplayFor(modelItem => item.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Author)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DateCreated)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DateEdited)
                </td>
                <td>
                    <a href='@Url.Action("Edit", "Project", new { id = item.ProjectID })'><img src='@Url.Content("~/Content/images/Edit16x16.png")' title="Edit"/></a> &nbsp;
                    <a href='@Url.Action("Details", "Project", new { id = item.ProjectID })'><img src='@Url.Content("~/Content/images/Details16x16.png")' title="Details" /></a> &nbsp;
                    <a href='@Url.Action("Delete", "Project", new { id = item.ProjectID })'><img src='@Url.Content("~/Content/images/Delete16x16.png")' title="Delete" /></a> &nbsp;
                    <a href='@Url.Action("Select", "Project", new { id = item.ProjectID })' class="select"  ><img src='@Url.Content("~/Content/images/Select16x16.png")' title="Select"  /></a> 
                </td>
            </tr>
         }
    </tbody>
</table>

在这种情况下,听起来好像缺少对排序库的引用,请尝试在jQuery用法的主
脚本
标记之前添加此项:

<script type="text/javascript" src="https://raw.github.com/padolsey/jQuery-Plugins/master/sortElements/jquery.sortElements.js"></script>


您是否已确保调试控制台(Internet Explorer=F12和Chrome=CTRL+SHIFT+J)中没有脚本错误,也请尝试查看呈现标记上的源代码,并用生成的标记替换JSFIDLE。是的,我想您已经了解了一些问题。调试控制台显示了这一点。
未捕获的TypeError:Object[Object Object]没有方法“sortElements”
同样,我已经尝试过我的标记,效果很好。我可能会添加,我正在使用最新的JQuery。@user1407758:我认为你的
thead
tbody
可能会弄乱库,然后在你的标记中,尝试删除它们以反映你在JSFIDLE示例中的标记。另外,你能粘贴你吗r将生成的标记粘贴到您的问题的编辑中。我在编辑中提供了标记,而且我删除了
thead
tbody
仍然没有任何内容。@user1407758:我刚刚将生成的标记和脚本粘贴到JSFIDLE中,效果很好…-您一定在页面的其他地方有脚本错误。请尝试
alert
ing单击
检查您的脚本是否有那么大的进展。已经进行了
警报
调试。几乎所有地方都进行了调试。我猜将重试。现在,即使单击也不会启动警报…我将重做脚本并重试。
<table id="projectTable">
    <tr>
        <th id="name_header">
            Name
        </th>
        <th id="author_header">
            Author
        </th>

        <th>
            Date Created
        </th>
        <th>
            Date Edited
        </th>
        <th style="text-align:right;"> <a href="/Project/Create"><button>&nbsp;Create&nbsp;</button></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
    </tr>
    <tr id='1' class="trow  none ">
        <td>
            Project 1
        </td>
        <td>
            Me
        </td>

        <td>
            8/24/2012 7:08:49 PM
        </td>
        <td>
             8/24/2012 7:08:49 PM
        </td>
        <td>
            <a href='/Project/Edit/1'><img src='/Content/images/Edit16x16.png' title="Edit"/></a> &nbsp;
            <a href='/Project/Details/1'><img src='/Content/images/Details16x16.png' title="Details" /></a> &nbsp;
            <a href='/Project/Delete/1'><img src='/Content/images/Delete16x16.png' title="Delete" /></a> &nbsp;
            <a href='/Project/Select/1' class="select"  ><img src='/Content/images/Select16x16.png' title="Select"  /></a> 
        </td>
    </tr>
    <tr id='2' class="trow  none ">
        <td>
            Test Project 2
        </td>
        <td>
            Me
        </td>

        <td>
            8/27/2012 5:42:32 PM
        </td>
        <td>
            8/27/2012 5:42:32 PM
        </td>
        <td>
            <a href='/Project/Edit/2'><img src='/Content/images/Edit16x16.png' title="Edit"/></a> &nbsp;
            <a href='/Project/Details/2'><img src='/Content/images/Details16x16.png' title="Details" /></a> &nbsp;
            <a href='/Project/Delete/2'><img src='/Content/images/Delete16x16.png' title="Delete" /></a> &nbsp;
            <a href='/Project/Select/2' class="select"  ><img src='/Content/images/Select16x16.png' title="Select"  /></a> 
        </td>
    </tr>
</table>
<script type="text/javascript" src="https://raw.github.com/padolsey/jQuery-Plugins/master/sortElements/jquery.sortElements.js"></script>