I have a datatables table setup
Mainpage.php
new DataTable('.dataTable',{
"pageLength" : 100,
scrollCollapse: true,
scrollY: '500px',
"bPaginate": false,
columnDefs: [{
"defaultContent": "-",
"targets": "_all"
}]
});
When a user does a thing, I reload the page. I would like the reloaded page to have the search filter activated after reload.
Here is the code on the page where a user does their thing.
<script>
$('body).on('//Some event),function(){
//get the search term
var searchTerm = $('#dt-search-2').val();
//reload
window.location.href = url+"?tab=licenses&search="+searchTerm;
});
</script>
On the MainPage.php
<script>
//get the search term from the parameters in url
var searchTerm = "<?php if (isset($_GET['search'])){
echo $_GET['search'];
}?>";
//populate the search field in datatables
$('#dt-search-2').val(searchTerm);
//What can i use here to trigger the actual filter?
</script>
I have tried
$('#dt-search-2').trigger('click');
$('#dt-search-2').focus();
Currently, I see the reloaded page and the value of the searchterm is populated in #dt-search-2, i just cant get the filter to actual go.