Bootstrap datatables search input won't change

18
January 06, 2019, at 9:30 PM

Im using bootstrap datatables, and im having a search input and whatever I do it won't remove Search text and add placeholder. I've seen examples here on stack and google but that didnt helped.

I believe this is the js for the search input:

function _fnFeatureHtmlFilter ( settings )
    {
        var classes = settings.oClasses;
        var tableId = settings.sTableId;
        var language = settings.oLanguage;
        var previousSearch = settings.oPreviousSearch;
        var features = settings.aanFeatures;
        var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
        var str = language.sSearch;
        str = str.match(/_INPUT_/) ?
            str.replace('_INPUT_', input) :
            str+input;
        var filter = $('<div/>', {
                'id': ! features.f ? tableId+'_filter' : null,
                'class': classes.sFilter
            } )
            .append( $('<label/>' ).append( str ) );
        var searchFn = function() {
            /* Update all other filter input elements for the new display */
            var n = features.f;
            var val = !this.value ? "" : this.value; // mental IE8 fix :-(
            /* Now do the filter */
            if ( val != previousSearch.sSearch ) {
                _fnFilterComplete( settings, {
                    "sSearch": val,
                    "bRegex": previousSearch.bRegex,
                    "bSmart": previousSearch.bSmart ,
                    "bCaseInsensitive": previousSearch.bCaseInsensitive
                } );
                // Need to redraw, without resorting
                settings._iDisplayStart = 0;
                _fnDraw( settings );
            }
        };
        var jqFilter = $('input', filter)
            .val( previousSearch.sSearch )
            .attr( 'placeholder', language.sSearchPlaceholder )
            .bind(
                'keyup.DT search.DT input.DT paste.DT cut.DT',
                _fnDataSource( settings ) === 'ssp' ?
                    _fnThrottle( searchFn, 400 ):
                    searchFn
            )
            .bind( 'keypress.DT', function(e) {
                /* Prevent form submission */
                if ( e.keyCode == 13 ) {
                    return false;
                }
            } )
            .attr('aria-controls', tableId);
        // Update the input elements whenever the table is filtered
        $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
            if ( settings === s ) {
                // IE9 throws an 'unknown error' if document.activeElement is used
                // inside an iframe or frame...
                try {
                    if ( jqFilter[0] !== document.activeElement ) {
                        jqFilter.val( previousSearch.sSearch );
                    }
                }
                catch ( e ) {}
            }
        } );
        return filter[0];
    }

As you know it datatables doesn't show in HTML, so its js.

How it looks, look at the search input

How I want it to look

Answer 1

you can use following code

oLanguage: {
            "sSearch": ""
        },

for Placeholder put the following code

$('.dataTables_filter input').attr("placeholder", "search...");

READ ALSO
Idangero Sniper: Add a slide

Idangero Sniper: Add a slide

I am trying to append a lazy loading slide within an ajax call but don't known why the image is not showing up

33
Node.js/MongoDB - querying dates

Node.js/MongoDB - querying dates

I'm having a bit of an issue understanding how to query dates; I think the issue might be with how my data is structuredHere is a sample document on my database

20
How to trigger file download on URL without extension

How to trigger file download on URL without extension

I am trying to trigger a download when the user clicks on a link

19
Catboost Regression. Function Extrapolation

Catboost Regression. Function Extrapolation

I'm new at ML and have a problem with catboostSo, I want to predict function value (For example cos | sin etc

21