Pug Datatables Uncaught ReferenceError: $ is not defined

Pug Datatables Uncaught ReferenceError: $ is not defined

shi_roshi_ro Posts: 3Questions: 2Answers: 0

Hi,

I am trying to use datatables with pug but * i keep getting an error

Uncaught ReferenceError: $ is not defined

I am using datatables locally and my code looks like this:

extends layout/base

block content

    #heading
      h1.text-center IL Clients

    #content
    //- Do it like this...You're already in JavaScript land after the -
    - var items = rows

      script.
        $(document).ready(function() {
          $('#resultTable').DataTable({
            "order": [[ 0, "desc" ]]
            });
        });
      
      div
        div

          table#resultTable.table.thead-light 
            thead 
              tr: th Clien Number
                  th Gender 
                  th Marital Status
                  th Phone Number 
                  th Group  
            tbody 
              each item in items

                tr 
                  td=item.clinic_number
                  td=item.gender
                  td=item.marital
                  td=item.phone_no
                  td=item.group_id
               

I have also tried moving the js script part below but nothing works. Any advise/recommendations will be appreciated.

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Perhaps you are not referencing jQuery anywhere.

This discussion has been closed.