Placeholder for DataTables Search

Placeholder for DataTables Search

jmyrtlejmyrtle Posts: 52Questions: 3Answers: 0

Is there a way of adding a text placeholder to a DataTables search bar? If so, how do I do it?

I've seen where I can use the language.searchPlaceholderoption, but it isn't working in my code.

Here is my current JSON script:

$(document).ready(function() {
    $('#dataTable').DataTable( {
        "processing": true,
        "serverSide": true,
        "order": [],
        "pageLength": 25,
        "ajax": "api/server.php",
    })
});

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921
    Answer ✓

    language.searchPlaceholder works in this example:
    http://live.datatables.net/wuvelewi/1/edit

    Please update the example to show the issue.

    Kevin

  • jmyrtlejmyrtle Posts: 52Questions: 3Answers: 0

    Ahhh... silly me. I had a syntax error but was able to get it resolved:

    $(document).ready(function() {
        $('#dataTable').DataTable( {
            "processing": true,
            "serverSide": true,
            "order": [],
            "pageLength": 25,
            "ajax": "api/server.php",
             language: {
            searchPlaceholder: "Enter Last Name"
        }
        });
    });
    
This discussion has been closed.