Search code examples
asp.net-mvc-5footable

Can't get footable to display


I'm new to ASP and MVC so I'm learning. I'm trying to implement footable in my ASP.NET MVC 5 test project (I ultimately want to use the pagination and sorting features, but one step at a time).

I have added the .js files and .css files to the project and included them in the BundleConfig.cs file (see below). I'm not sure if that is all I need to do in order to use them in my project.

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                  "~/Scripts/bootstrap.js",
                  "~/Scripts/respond.js",
                  "~/Scripts/footable.min.js",
                  "~/Scripts/footable.js"));

        bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css",
                  "~/Content/footable.bootstrap.min.css",
                  "~/Content/footable.bootstrap.css"));

I'm retrieving data from a MySQL database and passing that to my view but I'm just getting a standard html table, what am I doing wrong ?

Here is the view code :-

@model IEnumerable<MVC5Footable.Models.radacct>

@{
    ViewBag.Title = "Index";
}

<table class="footable">
    <thead>
        <tr>
            <th>@Html.DisplayNameFor(model => model.username)</th>
            <th>@Html.DisplayNameFor(model => model.framedipaddress)</th>
        </tr>
    </thead>

    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>@Html.DisplayFor(modelItem => item.username)</td>
                <td>@Html.DisplayFor(modelItem => item.framedipaddress)</td>
            </tr>
        }
    </tbody>
</table>


<!-- Initialize FooTable -->
<script>
    jQuery(function ($) {
        $('footable').footable();
    });
</script>

Hoping someone can help. Thanks.


Solution

  • A little late, but for the record: you forgot to include the dot.

    $('.footable').footable();