Step by step guide?

Step by step guide?

stevegsteveg Posts: 3Questions: 1Answers: 0

Does anyone know of a simple guide to making this work with MVC 5 applications? This is my first crack at using jquery and I can't make it work on an EF scaffolded view. tried to use this thread [ http://stackoverflow.com/questions/28442960/asp-net-mvc5-and-datatables-for-a-beginner-what-goes-where ] but no use other than to confirm that 'adding three lines of code' doesn't do it.

I must be being dumb but I can't make it work!
Many thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,096Questions: 1Answers: 10,390 Site admin

    I'm not aware of one, but there probably is if you Google for it.

    The key with DataTables is to:

    1. Have an HTML table
    2. Include jQuery and DataTables
    3. Call $().DataTable()

    The fact that you are using MCV5 is largely irrelevant since its a client-side library.

    See also the installation guide.

    Allan

  • stevegsteveg Posts: 3Questions: 1Answers: 0

    Thanks very much for getting back to me so quickly. Frustratingly, I've managed to get things to work in one solution but not another. I always get the error:

    Unhandled exception at line 4305, column 9 in http://localhost:35837/BusStops/Index

    0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'DataTable'

    when it reaches the line:

    $('#stoptbl').DataTable();

    Any idea what I've missed? The html table is correct I think and I have jquery and Datatables added in the _layout.

    Thanks again.
    Steve

  • allanallan Posts: 63,096Questions: 1Answers: 10,390 Site admin
    Answer ✓

    Without being able to see the page I really can't debug it. My best guess is that you are loading jQuery multiple times.

    Allan

  • stevegsteveg Posts: 3Questions: 1Answers: 0

    Quite an impressive guess! Spot on. Working a treat now and amazing bit of code.

    Many thanks
    Steve

This discussion has been closed.