Quantcast
Viewing all articles
Browse latest Browse all 82039

Pass url parameter and action on datatable loaded.

Hi Guys I have the following

// get the deal number
var url_string = window.location.href;
var url = new URL(url_string);
var urlDeal  = url.searchParams.get("deal");
console.log('dealID = ' + urlDeal);

// on loaded event Add the urlDeal if required
$('#dtDataChanged')
    .on('xhr.dt', function ( e, settings, json, xhr ) {
        alert('loaded');
// pass in urlDeal to the search box id and do the search
if (urlDeal !== 'null') { $('#searchDeal').val(urlDeal);}
    } )

I have created the search buttons using

     $('#dtDataChanged thead th').each( function (e) {
// don't add search box to column 1
        console.log(e);
        if(e!==1){
        if(e==0){ var title = $(this).text();
        $(this).html( '<input type="text" class = "form-control" id = "searchDeal" placeholder="Search '+title+'" />' ); }
        else{
        var title = $(this).text();
        $(this).html( '<input type="text" class = "form-control" placeholder="Search '+title+'" />' );}
      }
    } );


     tableDataChanged.columns().every( function () {
        var that = this;
        //console.log(that);

        $( 'input', this.header() ).on( 'keyup change', function () {
            if ( that.search() !== this.value ) {
                that
                    .search( this.value )
                    .draw();
              console.log(this.value);
            }
        } );

    } );
  1. I don't see the alert on '.on('xhr.dt', function'
  2. The inputs are listing for keyup change. What do I add to force if (urlDeal !== 'null') { $('#searchDeal').val(urlDeal);} to perform the search. I need the client to see the urlDeal in the search box so he knows to delete it to clear the search.

Cheers

Steve Warby


Viewing all articles
Browse latest Browse all 82039

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>